Details
-
Improvement
-
Resolution: Done
-
Major - P3
-
None
-
None
Description
The following is misleading:
The mongo shell automatically prints the results of the find() method if the returned cursor is not assigned to a variable.
The above "trick" only works if the assignment is in an initializing statement (var c = db.collection.find()), but not simply if the "cursor is assigned to a variable" (c = db.collection.find()). The latter doesn't work because the assignment operator returns an expression, and if the given expression evaluates to a cursor object, the mongo shell calls next() on the cursor and prints the results.