Tuesday, May 16, 2017

Get "pretty" result always without typing .pretty() on mongo.

When executing mongo commands we put .pretty() at the end to get a readable out put.

Ex:
db.myTable.find({"id":"123"}).pretty()
However there is a way to avoid this command. Just enter the following line into "$HOME/.mongorc.js"
DBQuery.prototype._prettyShell = true
That will enable pretty print globally by default.

No comments: