findOne() results in pretty-print json object.
find() results in jarbled json object.
How can I make find() the same as findOne(), when it comes to display in the mongo shell?
findOne() results in pretty-print json object.
find() results in jarbled json object.
How can I make find() the same as findOne(), when it comes to display in the mongo shell?
It may not have been available at the time the question was asked, but to make the default output for all find() queries to be pretty, I use:
DBQuery.prototype._prettyShell = true
I also add the following:
DBQuery.prototype.ugly = function() {
this._prettyShell = false;
return this;
}
which enables me to uglify the results of a single find() query using:
db.mycollection.find().ugly()
I typically add both prototype declarations into my ~/.mongorc.js file so they are available in all mongo cli shells.