MongoDB: cursor.hasNext() method
cursor.hasNext
The cursor.hasNext() method is used to return true if the cursor has more documents to return.
Syntax:
cursor.hasNext()
Return
Boolean
Sample document in the restaurants collection:
Example: MongoDB: cursor.hasNext() method
The following example returns the boolean true because the cursor ( db.restaurants.find() ) has more documents to return.
Output:
> db.restaurants.find().hasNext(); true
Retrieve the restaurants data from here
Previous:
cursor.forEach() method
Next:
cursor.hint() method