In MySQL I can do select * from some_table into outfile 'myfile.csv'
Is there something similar in MongoDB? Cannot find relevant information in the documenatation. I'm working with mongodb 2.2.3.
Asked
Active
Viewed 33 times
0

Michael Kruglos
- 1,205
- 14
- 26
-
this might help .https://stackoverflow.com/questions/14478304/redirect-output-of-mongo-query-to-a-csv-file – user2263572 Dec 04 '18 at 00:16
1 Answers
1
You might want to use mongoexport
, which produces a JSON or CSV export of data stored in a MongoDB instance
mongoexport --db dbName --collection collectionName --jsonArray --pretty --query '{"key": "value"}' --output output.json
For more details, please refer to mongoDB documentation.

Jake Noh
- 216
- 1
- 7