| |
read source history
findOne()
MongoDB Driver Function Reference
Retrieves the first document matching the filter criteria from a collection.
More information can be found in the corresponding entry of the MongoDB Manual.
<collection>.findOne([<filter>[, <options>]])
|
Arguments
<collection> | | The target collection. |
<filter> | | A filter expression using query operators. |
<options> | | A BOSN document specifying options. |
|
Options
{ allowDiskUse: <boolean>, allowPartialResults: <boolean>, batchSize: <int>, comment: <string>,
max: <document>, maxAwaitTime: <long>, min: <document>, noCursorTimeout: <boolean>,
returnKey: <boolean>, showRecordId: <boolean>, collation: <document>, hint: <document> }
allowDiskUse | | Allows to write to disk while executing. |
allowPartialResults | | Allows partial results if some shards are missing. |
batchSize | | Sets the batch size. |
comment | | Sets the comment. |
max | | Sets the maximum key value. |
maxAwaitTime | | Sets the maximum await time (in milliseconds). |
min | | Sets the minimum key value. |
noCursorTimeout | | Sets if the cursor will time out. |
returnKey | | Sets if only index keys will be returned. |
showRecordId | | Sets if the record ID will be added to the result. |
collation | | A document specifying the collation. |
hint | | A document specifying a hint. |
|
Example
db.employees.findOne({ salary: { $gt: 700000 }});
|
Returns one document from the employee collection with a salary greater than 700000.
home | MongoDB Driver Function Reference | MongoDB Driver
|