[DOCS-3618] Page on iterating a cursor has example that does not iterate Created: 18/Jun/14  Updated: 23/Jun/14  Resolved: 23/Jun/14

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: v1.3.7

Type: Improvement Priority: Minor - P4
Reporter: Andrew Erlichson Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 9 years, 34 weeks, 2 days ago

 Description   

On this page, which google shows when users try to understand how to iterate through results of a cursor in javascript using the Mongo shell, there is no example that iterates document by document, w/o bringing the result into memory.

In particular, this example needs a loop:

var myCursor = db.inventory.find( { type: 'food' } );
var myDocument = myCursor.hasNext() ? myCursor.next() : null;
 
if (myDocument) {
    var myItem = myDocument.item;
    print(tojson(myItem));
}



 Comments   
Comment by Githook User [ 23/Jun/14 ]

Author:

{u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-3618 change examples to iterate cursor
Branch: master
https://github.com/mongodb/docs/commit/4d9b502d6867645eaf07eb2b0f18952b14b29e33

Generated at Thu Feb 08 07:46:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.