See also: MongoDB\Collection::distinct()
See also: http://docs.mongodb.org/manual/reference/command/distinct/
Inheritance: implements Phalcon\Db\Adapter\MongoDB\Operation\Executable
Exemplo n.º 1
0
 /**
  * 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);
 }