Search code examples
mongodbmongodb-shell

Slowing down MongoDB shell output for large documents?


I am trying to inspect a document that is larger than the print buffer for the Windows command window. For some queries more allows you to type it for more output. Is there a way to apply this to other commands?

For instance I might do db.coll.findOne() which greatly surpasses the print buffer. I'd like to see as much as fits, type it, see more, etc.


Solution

  • You could use this workaround:

    Make a file with your command... i.e. tmp.txt containing

    db.coll.findOne()
    

    Then execute the query via command line - piping the output to an output text file like this:

    mongo yourDatabaseName < tmp.txt > output.txt