How do you export all the records in a MongoDB collection to a .csv
file?
mongoexport --host localhost --db dbname --collection name --type=csv > test.csv
This asks me to specify name of the fields I need to export. Can I just export all the fields without specifying the names of fields?
If you want, you can export all collections to csv without specifying
--fields
(will export all fields).From http://drzon.net/export-mongodb-collections-to-csv-without-specifying-fields/ run this bash script