cursor.count() - Return the number of documents returned by the find() method on a collection command
Returns the number of documents returned by the find() method on a
collection.
Syntax diagram
Command parameters
- document
- A JSON query for filtering a subset of data in a
find()method.
Examples
The following example shows the command syntax for returning the number of documents returned by
the
find() method on the collection,
books:db.books.find().count()The following example shows the
output returned from including the count option in the find()
operation:15The following example shows the command syntax for returning the number of documents for an
author that are returned by the
find() method on the collection,
books: db.books.find({author: "Tolkien, J.R"}).count()The
following example shows the output returned from including the count option in the
find({author...}) operation::2