How do you export all the records in a MongoDB collection to a .csv file?
mongoexport --host localhost --db dbname --collection name --type=csv
Add the --fields parameter as comma separated field names enclosed in double inverted quotes:
--fields ",..."
This is complete example:
mongoexport --host Cluster0-shard-0/shard1URL.mongodb.net:27017,shard2URL.mongodb.net:27017,shard3URL.mongodb.net:27017 --ssl --username --password --authenticationDatabase admin --db --collection --type