The cursor object returned by find() supports forEach() , so you can use:
db.foo.find().forEach(printjson)
However, note that unlike the default output find() , which shows the first 10 objects, then you can choose whether to continue the repeat or not, forEach() will iterate the entire result set. Thus, if your query returns a lot of results, this may take some time and may not be very useful. limit() is your friend here.
dcrosta Jul 20 '11 at 1:40 2011-07-20 01:40
source share