Custom Search

Wednesday, May 8, 2019

How to Redirect output of mongoDB query to a JSON file

a)
$ vim myquery.js
printjson(db.media.find().toArray())

b)
mongo mediadb myquery.js
mongo mediadb myquery.js > output.json

mongo [host]/[dbname] -u [username] -p [password] myquery.js > output.json

No comments:

Post a Comment