How do I export the results of a MongoDB command to a flat file
For example, If I am to get db.collectionname.find() into a flat file.
db.collectionname.find()
I tried
mongoexport --host 127.0.0.1 --port 27017 --username youruser -p yourpass \ -d yourDatabaseName -c collectionName --type csv \ --fields field1,field2 -q '{"field1" : 1495730914381}' \ --out report.csv