[SERVER-1071] Add pretty() feature to find() Created: 01/May/10  Updated: 12/Jul/16  Resolved: 03/May/10

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: 1.5.2

Type: New Feature Priority: Minor - P4
Reporter: Greg Zoller Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Getting a pretty rendering of json is fairly common (to me anyway) in the shell. Today I need to do something like:

db.foo.find().forEach(function

{print(tojson(x));}

);

Wow... that's a lot of typing. Would it be simple thing to define a macro for the above code so that you could do something like:

db.foo.find().pretty()



 Comments   
Comment by Greg Zoller [ 22/Apr/11 ]

I've been so happy using this cool feature I just noticed that I couldn't find it in the docs. Should probably be described in the mongo shell docs, at a minimum in the reference.

Comment by auto [ 03/May/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: pretty() option for cursor in shell SERVER-1071
http://github.com/mongodb/mongo/commit/1e9856247a9ad5dca733d4fce48d8500672b1add

Comment by Eliot Horowitz (Inactive) [ 03/May/10 ]

> db.foo.find()

{ "_id" : ObjectId("4bdf157067103eab207b86f5"), "a" : 1, "b" : 2, "c" : 3, "d" : 4, "e" : 5, "f" : 6 }

> db.foo.find().pretty()
{
"_id" : ObjectId("4bdf157067103eab207b86f5"),
"a" : 1,
"b" : 2,
"c" : 3,
"d" : 4,
"e" : 5,
"f" : 6
}
>

Generated at Thu Feb 08 02:55:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.