- Reference >
mongosh
Methods >- Cursor Methods >
- cursor.pretty()
cursor.pretty()¶
On this page
Definition¶
-
cursor.
pretty
()¶ Important
mongosh
MethodThis page documents a
mongosh
method. 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
mongo
shell 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: