Articles → MONGODB → Cursor In Mongodb

Cursor In Mongodb






What Is A Cursor?





Example




Picture showing executing the find method in MongoDB
Click to Enlarge



Picture showing the text type it for more once find method is executed
Click to Enlarge




Assigning Cursor Object To A Variable




Picture showing assigning the cursor to the variable
Click to Enlarge


Next And Hasnext Method




Picture showing the output of next method in cursor
Click to Enlarge



Picture showing the output of hasNext method in cursor
Click to Enlarge


Loop Through The Cursor




cursor.forEach(doc=>{printjson(doc)})



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, February 28, 2023
 
Updated On  -  Tuesday, March 26, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250