Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-3618

Page on iterating a cursor has example that does not iterate

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • v1.3.7
    • None
    • manual
    • None

    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));
      }

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            erlichson Andrew Erlichson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9 years, 34 weeks, 2 days ago