/**
* Finds the distinct values for a specified field across the collection.
*
* @see Distinct::__construct() for supported options
*
* @param string $fieldName Field for which to return distinct values
* @param array|object $filter Query by which to filter documents
* @param array $options Command options
*
* @return mixed[]
*/
public function distinct($fieldName, $filter = [], array $options = [])
{
if (!isset($options['readConcern'])) {
$options['readConcern'] = $this->readConcern;
}
if (!isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
$operation = new Distinct($this->databaseName, $this->collectionName, $fieldName, $filter, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}