4 mai 2014

Pretty print in MongoDB

The bare minimum: pretty

Use JS's pretty function to prettify your JSON documents or collections within the Mongo's shell:
db.find({}).pretty()
Here's the difference with a simple example:
You can even turn it as your default in your preference file ~/.mongorc.js using this command:
echo "DBQuery.prototype._prettyShell = true" >> ~/.mongorc.js
Thanks to Lee Machin for this tip: https://coderwall.com/p/3vfw9a

The cleanest one: Mongo-Hacker

Mongo-Hacker adds much more than a simple prettification: it adds colors and some additional API. Installing it with the following commands:
npm -g install mongo-hacker
Now, here is the same example with some nice hacking:

Aucun commentaire:

Enregistrer un commentaire