title: How to export collection to CSV in MongoDB?
body: <p>How do you export all the records in a MongoDB collection to a <code>.csv</code> file?</p>
  
  <pre><code>mongoexport --host localhost --db dbname --collection name --type=csv &gt; test.csv
  </code></pre>
  
  <p>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?</p>