public function distinct($key, array $query = [])
{
try {
return array_map([TypeConverter::class, 'toLegacy'], $this->collection->distinct($key, TypeConverter::fromLegacy($query)));
} catch (\MongoDB\Driver\Exception\Exception $e) {
return false;
}
}
/** * Retrieve a list of distinct values for the given key across a collection. * * @param string $selector field selector * @param array|callable|\Sokil\Mongo\Expression $expression expression to search documents * @return array distinct values */ public function getDistinct($selector, $expression = null) { if ($expression) { return $this->_mongoCollection->distinct($selector, Expression::convertToArray($expression)); } return $this->_mongoCollection->distinct($selector); }