- Reference >
mongoshMethods >- Cursor Methods >
- cursor.pretty()
cursor.pretty()¶
On this page
Definition¶
-
cursor.pretty()¶ Important
mongoshMethodThis page documents a
mongoshmethod. This is not the documentation for a language-specific driver such as Node.js.For MongoDB API drivers, refer to the language-specific :driver:`MongoDB driver documentation </>`.
For the legacy
mongoshell documentation, refer to the documentation for the corresponding MongoDB Server release:Configures the cursor to display results in a format that is easy to read.
The
pretty()method has the following prototype form:
Behavior¶
The pretty() method:
- Does not change the output format in
mongosh. - Changes the output format in the legacy mongo shell.
Examples¶
Consider the following document:
By default, db.collection.find() returns data in a dense format:
By using cursor.pretty() you can set the cursor to return data in a
format that is easier to read: