Phalcon\Db\Adapter\MongoDB\Collection::distinct PHP Method

distinct() public method

Finds the distinct values for a specified field across the collection.
See also: Distinct::__construct() for supported options
public distinct ( string $fieldName, array | object $filter = [], array $options = [] ) : mixed[]
$fieldName string Field for which to return distinct values
$filter array | object Query by which to filter documents
$options array 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);
    }