robbiblubber.org

help | login | search:  
<<

Home Page
Index

Projects

Utility Suite
Data Suite
Bad Wolf Suite
WeakWiki

User Docs

ConfigNotepad
LED
rqoon
Nuub

Code Docs

.NET
Java
PHP

robbiblubber.org

Specs
Articles

Sources















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 [[https://docs.mongodb.com/manual/reference/method/db.collection.findOne/index.html|MongoDB Manual]].


[[[@cG

<collection>.findOne([<filter>[, <options>]])

]]]


**Arguments**

[[[@w

|@t0@r0@c0 <collection> | | The target collection. |
| <filter> | | A filter expression using [[https://docs.mongodb.com/manual/reference/operator/|query operators]]. |
| <options> | | A BOSN document specifying options. |

]]]


**Options**

[[[@cw

{ allowDiskUse: <boolean>, allowPartialResults: <boolean>, batchSize: <int>, comment: <string>,
max: <document>, maxAwaitTime: <long>, min: <document>, noCursorTimeout: <boolean>,
returnKey: <boolean>, showRecordId: <boolean>, collation: <document>, hint: <document> }
<<@f:text>>
|@t0@r0@c0 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 [[https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#collation|collation]]. |
| hint | | A document specifying a [[https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/#ex-deletemany-hint|hint]]. |
<<@/f>>
]]]


**Example**

[[[@cw

db.employees.findOne({ salary: { $gt: 700000 }});

]]]

Returns one document from the employee collection with a salary greater than 700000.



----
[[Main|home]] | [[MongoDB Driver Function Reference]] | [[MongoDB Driver]]