cursor.itcount() – Count the number of documents remaining in a cursor command

Counts the number of documents remaining in a cursor.

Syntax diagram

Read syntax diagramSkip visual syntax diagramcursor.itcount()

Command parameters

No parameters.

Examples

The following example shows the command syntax for counting the number of documents remaining in a cursor for an author in the collection, books:
db.coll.find( {author: "Tolkien, J.R"} ).itcount()
The following example shows the output returned from including the itcount option in the find({author...}) operation:
1