cursor.hasNext() - Check whether there is a next document in the DBCursor command
Checks whether there is a next document in a DBCursor object.
Syntax diagram
Command parameters
No parameters.
Examples
The following example shows the command syntax for checking whether there is a
Next
document in the DBCursor of the collection,
books
:db.books.find().hasNext()
The following example shows
the output returned from including the hasNext option in the
find()
operation:true
The 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"} ).hasNext()
The following example
shows the output returned from including the hasNext option in the
find({author...})
operation::true