Reputation: 1378
Is it possible to pipe results in to a pager from within a mongo shell?
The mysql cli equivalent would be:
mysql> pager less
Upvotes: 14
Views: 4277
Reputation: 3289
You can try to use mongo --eval option. Something like:
mongo <db> --quiet --eval '<query>' | less
Upvotes: 4
Reputation: 1312
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.
Upvotes: 2
Reputation: 12240
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.
Upvotes: 3