您的位置:首页 > 数据库 > Mongodb

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

2016-09-27 16:57 330 查看
How
to print out more than 20 items (documents) in MongoDB's shell?

db.foo.find().limit(300)


won't do it. It still prints out only 20 documents.
db.foo.find().toArray()
db.foo.find().forEach(printjson)


will both print out very expanded view of each document instead of the 1-line version for 
find()
:

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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐