title: Export large number of documents into text file using mongoose
body: <p>Im am having about 60,000 records imported into MongoDb using Mongoose schema from different source files. Now I wanted to perform an export into text file of selected records (also applying validations on fields- e.g. there are two fields in the mongoose schema email1 and email2. I have to select between email1 and email2 as a field(Email) in the export file for each records). I referred the plugin mongoose-to-csv. Is there any other plugins or methods available for this export to txt files?</p>
  
  <p>And yes I tried using fs module.</p>
  
  <p>I want the result something like this in a txt document.</p>
  
  <pre><code>"ID","First_Name","Last_Name","Email"
  123,ABC, DEF, emailABC@example.com
  456,GHI, JKL, emailGDI@exaple.com
  .....
  </code></pre>
  
  <p>my code was</p>
  
  <pre><code>Model.find({"ID":{$exist:true}},function(error,result)
  {       
  var csv = json2csv({data:results, fields:fields, hasCSVColumnTitle:true});  
  fs.writeFile('TestFile.csv',csv,function(err)
  {   
  });  
  });
  </code></pre>
  
  <p>Can we write these comma separated values into a text file?</p>