public function distinct($fieldName, $filter = [], array $options = [])
    {
        if ( ! isset($options['readPreference'])) {
            $options['readPreference'] = $this->readPreference;
        }

        $server = $this->manager->selectServer($options['readPreference']);

        if ( ! isset($options['readConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForReadConcern) && ! $this->isInTransaction($options)) {
            $options['readConcern'] = $this->readConcern;
        }

        $operation = new Distinct($this->databaseName, $this->collectionName, $fieldName, $filter, $options);

        return $operation->execute($server);
    }
public function distinct($fieldName, $filter = [], array $options = [])
    {
        if ( ! isset($options['readPreference'])) {
            $options['readPreference'] = $this->readPreference;
        }

        $server = $this->manager->selectServer($options['readPreference']);

        if ( ! isset($options['readConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForReadConcern) && ! $this->isInTransaction($options)) {
            $options['readConcern'] = $this->readConcern;
        }

        $operation = new Distinct($this->databaseName, $this->collectionName, $fieldName, $filter, $options);

        return $operation->execute($server);
    }
public function distinct ( $ fieldName , $ filter = [ ] , array $ options = [ ] ) { if ( ! isset ( $ options [ 'readPreference' ] ) ) { $ options [ 'readPreference' ] = $ this -> readPreference ; } $ server = $ this -> manager -> selectServer ( $ options [ 'readPreference' ] ) ; if ( ! isset ( $ options [ 'readConcern' ] ) && \ MongoDB \ server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) && ! $ this -> isInTransaction ( $ options ) ) { $ options [ 'readConcern' ] = $ this -> readConcern ; } $ operation = new Distinct ( $ this -> databaseName , $ this -> collectionName , $ fieldName , $ filter , $ options ) ; return $ operation -> execute ( $ server ) ; }
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[]
@throws UnexpectedValueException if the command response was malformed
@throws UnsupportedException if options are not supported by the selected server
@throws InvalidArgumentException for parameter/option parsing errors
@throws DriverRuntimeException for other driver errors (e.g. connection errors)
Finds the distinct values for a specified field across the collection .