[DOCS-1720] "mongo shell automatically prints results of find" misleading Created: 17/Jul/13  Updated: 30/Oct/23  Resolved: 22/Jul/13

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: J Rassi 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: 10 years, 26 weeks, 5 days ago

 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.



 Comments   
Comment by auto [ 16/Aug/13 ]

Author:

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

Message: DOCS-1720 cursor assignment with var keyword in mongo shell
Branch: master
https://github.com/mongodb/docs/commit/c70c2e3794c5828decdfff800c509ad8d6816882

Comment by Kay Kim (Inactive) [ 22/Jul/13 ]

integrated as part of the crud reorganization

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