Last Updated: February 25, 2016
·
2.831K
· leemachin

Pretty print MongoDB queries in REPL

Make your query more readable when using the REPL by chaining pretty() on to the end of it:

db.find({})
     .limit(10)
     .pretty()

Don't want to do it for every query? Enable it by default!

Just paste this into your terminal (not into the Mongo REPL):

echo "DBQuery.prototype._prettyShell = true" >> ~/.mongorc.js

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside