|
| |
read source history
distinct()
MongoDB Driver Function Reference
Retrieves distinct field values from documents matching the filter criteria from a collection.
More information can be found in the corresponding entry of the MongoDB Manual.
<collection>.distinct(<field>[, <filter>[, <options>]])
|
Arguments
| <collection> | | The target collection. |
| <field> | | The field name. |
| <filter> | | A filter expression using query operators. |
| <options> | | A BOSN document specifying options. |
|
Options
{ maxTime: <long>, collation: <document> }
| maxTime | | Sets the maximum operation time (in milliseconds). |
| collation | | A document specifying the collation. |
|
Return Value
Returns a result set (cursor).
|
Example
db.employees.distinct("age", { salary: { $gt: 700000 }});
|
Returns a distinct list of ages from the employee collection with a salary greater than 700000.
home | MongoDB Driver Function Reference | MongoDB Driver
|