Pretty print in MongoDB shell as default

前端 未结 8 1771
予麋鹿
予麋鹿 2020-12-07 06:50

Is there a way to tell Mongo to pretty print output? Currently, everything is output to a single line and it\'s difficult to read, especially with nested arrays and document

8条回答
  •  佛祖请我去吃肉
    2020-12-07 07:13

    Got to the question but could not figure out how to print it from externally-loaded mongo. So:

    This works is for console: and is prefered in console, but does not work in external mongo-loaded javascript:

    db.quizes.find().pretty()
    

    This works in external mongo-loaded javscript:

    db.quizes.find().forEach(printjson)
    

提交回复
热议问题