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

前端 未结 6 1092
南笙
南笙 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:11

    Could always do:

    db.foo.find().forEach(function(f){print(tojson(f, '', true));});
    

    To get that compact view.

    Also, I find it very useful to limit the fields returned by the find so:

    db.foo.find({},{name:1}).forEach(function(f){print(tojson(f, '', true));});
    

    which would return only the _id and name field from foo.

提交回复
热议问题