有没有办法仅通过使用 Linux shell 命令或运行脚本将 MongoDB find() 查询的输出写入文件?
现在我必须一步一步地手动输入。例子:
$ mongo
> use owndb
> db.CollectionName.find(<query>) ### and then copy and paste the result on a text editor
最佳答案
你可以试试这个:
mongo --quiet dbname --eval 'printjson(db.collection.find().toArray())' > output.json
关于MongoDB find() 输出到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47446775/