It would be really nice to be able to view the output with colorized keys and values.
Find() Method. In MongoDB, find() method is used to select documents in a collection and return a cursor to the selected documents. Cursor means a pointer that points to a document, when we use find() method it returns a pointer on the selected documents and returns one by one.
To list all collections in Mongo shell, you can use the function getCollectionNames().
To open up the MongoDB shell, run the mongo command from your server prompt. By default, the mongo command opens a shell connected to a locally-installed MongoDB instance running on port 27017 . Try running the mongo command with no additional parameters: mongo.
The cursor. pretty() method is used to configure the cursor to display results in an easy-to-read format. Syntax: cursor.pretty() The pretty() method has the following prototype form: db.collection.find(<query>).pretty()
Check out this shell extension I made called Mongo-Hacker that has various enhancements:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With