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
Try this - returns a json file with the data of the query, you can change .json for .txt and other.
.json
.txt
mongoexport --db products --collection clicks --query '{"createdInt":{$gte:20190101}, "clientId":"123", "country":"ES"}' --out clicks-2019.json