findOne() - Find the first offset document

Find the first document that matches the query after you skip a specified number of rows.

Syntax diagram

Read syntax diagramSkip visual syntax diagramdb.collection. findOne( query,select.skipoffset )

Command arguments

query
This optional argument specifies a filter to select a subset of documents.
select
This optional argument specifies a selection of fields to include or exclude in the query.
offset offset
This optional argument specifies a JSON object to skip some rows.

Example

Example 1: Use the db.collection.findOne() method to return a single record.
db.books.findOne({author: "Tolkien, J.R"}, {title: 1, price:1})
Sample output:
{
  "_id":{"$oid":"51f94b6a6bca2ee58280ef28"},
  "title":"The Hobbit",
  "price":5.0
  }