The Mongo shell already parses the results if the returned cursor is not assigned to a variable. From the documentation:
... in the mongo shell, if the returned cursor is not assigned to a variable using the var keyword, then the cursor is automatically repeated up to 20 times to print up to the first 20 documents that match the query. The mongo shell will offer to enter it into iteration 20 more times.
You can set the DBQuery.shellBatchSize attribute to change the iteration number from the default value of 20.
source share