File write operations in mongo script?

后端 未结 6 1575
执念已碎
执念已碎 2020-12-07 22:22

Is this possible to write the query result to the file from mongo js script. I have searched a lot, but I didn\'t find any solution.

ex:-

cursor = db         


        
6条回答
  •  执念已碎
    2020-12-07 23:07

    http://www.mongodb.org/display/DOCS/Scripting+the+shell paragraph "Differences between scripted and interactive/ Printing".

    ./mongo server.com/mydb --quiet --eval "db.users.find().forEach(printjson);" > 1.txt
    

提交回复
热议问题