title: Export mongodb collection data to csv file in node js
body: <p>I have created a mongodb collection in mongolab and want to print all documents in that collecton. I have mongolab and the url of mongolab to get connected with the collection is -</p>
  <p>mongodb://user:1234@xyz.mongolab.com:41248/new</p>
  <p>The sample document structure is -</p>
  <pre><code>{
      &quot;_id&quot;: &quot;9759572745-Sing&quot;,
  
     &quot;details&quot;: {
      &quot;Gender&quot;: &quot;M&quot;,
      &quot;PreTrainingStatus&quot;: &quot;Fresher&quot;,
      &quot;Religion&quot;: &quot;Hindu&quot;,
      &quot;attendanceInPercentage&quot;: &quot;&quot;,
      &quot;batchHolders&quot;: {
          &quot;AssessmentDate&quot;: &quot;Thu Jul 16 2015&quot;,
          &quot;CourseFee&quot;: &quot;7500&quot;,
          &quot;isEditable&quot;: false
      },
      &quot;batchID&quot;: &quot;282726&quot;,
      &quot;eid&quot;: &quot;&quot;,
      &quot;whereDidYouHearAboutStar&quot;: &quot;---Select---&quot;,
      &quot;skillInstructorOrTrainerName&quot;: &quot;282726&quot;,
      &quot;specificGovtInstitutetieups&quot;: &quot;---Select---&quot;,
      &quot;isSelected&quot;: false,
      &quot;isEditable&quot;: false
  },
  &quot;addedOnMs&quot;: 1439455766000,
  &quot;submittedOnMs&quot;: 1439454813000,
  &quot;latitude&quot;: &quot;27.409566879272&quot;,
  &quot;longitude&quot;: &quot;77.69295501709&quot;,
  &quot;locationName&quot;: &quot;Uttar Pradesh 281006,null&quot;
  }
  </code></pre>
  <p>I want to Print it and all nested properties to be displayed in a column.
  But I am not able to do so, Please help.</p>
  <p>Thank you (In Advance),
  Dia</p>