Is it possible to pipe results in to a pager from within a mongo shell?
The mysql cli equivalent would be:
mysql> pager less
Is it possible to pipe results in to a pager from within a mongo shell?
The mysql cli equivalent would be:
mysql> pager less
You can try to use mongo --eval option. Something like:
mongo <db> --quiet --eval '<query>' | less
Mongo shell already paginates 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 iterated up to 20 times to print up to the first 20 documents that match the query. The mongo shell will prompt Type it to iterate another 20 times.
You can set the DBQuery.shellBatchSize attribute to change the number of iteration from the default value 20.
It doesn't seem possible, but you can output to a file, and then read your file with a pager in another terminal:
$ mongo | tee file.txt
See Printing Mongo query output to a file while in the mongo shell.