Is there a way to tell Mongo to pretty print output? Currently, everything is output to a single line and it's difficult to read, especially with nested arrays and documents.
相关问题
- MongoDB can not create unique sparse index (duplic
- Spring Data MongoDB - lazy access to some fields
- Golang mongodb aggregation
- How to convert from Timestamp to Mongo ObjectID
- Is it possible to pass command-line arguments to @
相关文章
- mongodb有没有什么办法禁止读取数据的时候进行缓存
- mongodb-aggregate聚合查询分组后如何获得多字段
- mongodb error: how do I make sure that your journa
- How to track MongoDB requests from a console appli
- Linux - change the hostname in the CLI
- MongoError: cannot infer query fields to set, path
- Pymongo $in Query Not Working
- django.core.exceptions.ImproperlyConfigured: '
Since it is basically a javascript shell, you can also use
toArray()
:However, this will print all the documents of the collection unlike
pretty()
that will allow you to iterate. Refer: http://docs.mongodb.org/manual/reference/method/cursor.toArray/(note: this is answer to original version of the question, which did not have requirements for "default")
You can ask it to be pretty.
Give a try to Mongo-hacker(node module), it alway prints pretty. https://github.com/TylerBrock/mongo-hacker
More it enhances mongo shell (supports only ver>2.4, current ver is 3.0), like
I am using for while in production env, no problems yet.
Check this out:
Oh so i guess .pretty() is equal to:
You can add
to your file in
$HOME/.mongorc.js
to enable pretty print globally by default.