MongoDB Documentation, Release 3.0.4 { "_id" : 1, "scores" : [ { "attempt" : 3, "score" : 7 }, { "attempt" : 2, "score" : 8 }, { "attempt" : 1, "score" : 10 } ] } var myCursor = db.inventory.find( { type: 'food' } ); while (myCursor.hasNext()) { printjson(myCursor.next()); } var myCursor = db.inventory.find( { type: 'food' } ); while (myCursor.hasNext()) { print(tojson(myCursor.next())); } var myCursor = db.inventory.find( { type: 'food' } ); myCursor The db.collection.find() method returns a cursor. To access the documents, you need to iterate the cursor. However, in the mongo shell, if the returned cursor is not assigned to a variable using the var keyword, then the cursor is automatically iterated up to 20 times to print up to the first 20 documents in the results. The following describes ways to manually iterate the cursor to access the documents or to use the iterator index. In the mongo shell, when you assign the cursor returned from the find() method to a variable using the var keyword, the cursor does not automatically iterate. You can call the cursor variable in the shell to iterate up to 20 times 14 and print the matching documents, as in the following example: You can also use the cursor method next() to access the documents, as in the following example: As an alternative print operation, consider the printjson() helper method to replace print(tojson()) : You can use the cursor method forEach() to iterate the cursor and access the documents, as in the following example: Chapter 3. MongoDB CRUD Operations 110 14 You can use the DBQuery.shellBatchSize to change the number of iteration from the default value 20 . See Executing Queries (page 273) for more information. 3.3.7 Iterate a Cursor in the mongo Shell Manually Iterate the Cursor See also: • $push operator, • $each modifier, • $sort modifier, and • $slice modifier.