How to print out more than 20 items (documents) in MongoDB's shell?

前端 未结 6 1118
南笙
南笙 2020-11-28 00:22
db.foo.find().limit(300)

won\'t do it. It still prints out only 20 documents.

db.foo.find().toArray()
db.foo.find().forEach(printjs         


        
6条回答
  •  天涯浪人
    2020-11-28 01:18

    In the mongo shell, if the returned cursor is not assigned to a variable using the var keyword, the cursor is automatically iterated to access up to the first 20 documents that match the query. You can set the DBQuery.shellBatchSize variable to change the number of automatically iterated documents.

    Reference - https://docs.mongodb.com/v3.2/reference/method/db.collection.find/

提交回复
热议问题