After entering through MongoDB's built-in shell, if you run db.coll_name.findOne(), you'll notice the returned data is nicely formatted and easy on the eyes. But if you switch it up and use db.coll_name.find() instead, you're instantly hit with a flood of unformatted data that's pretty much unreadable. Fortunately, it's easy to tweak the output to make it look much nicer.
There are two ways to do this.
The first is to append .pretty() to your query.
db.coll_name.find().skip(10).limit(3).pretty()pretty() at the end—the result is then displayed in a formatted way.
The other way is through a configuration file.
Add the following line to $HOME/.mongorc.js:
JavaScript
DBQuery.prototype._prettyShell = truefind results will be automatically formatted.
Comments
No comments yet — be the first to write one.