title: node.js export dynamic data to csv file
body: <p>I am struggling to write data to a CSV in Node.js.</p>
  
  <p>i tried  this code.</p>
  
  <pre><code>       async.auto({
          user: function(cb){
              User.findOne({'memberid': currMemberId}).exec(cb);
          },
          billing : function(cb){
             Payment.find({'memberid' :currMemberId}).exec(cb);  
          },
          trans: function(cb){
             Transaction.find({'id':p.ids}) .exec(cb);
          }
      },function allDone(err, async_data) {
           var data= async_data.trans;
              createCSV = function(data){
                      csv().from(data).to(fs.createWriteStream("c:/temp/sample.csv")); 
  
             } 
  
     });
  </code></pre>
  
  <p>but it doesn't seem to work. can someone please help? I want to fetch some data from database and  export this data to csv file.database I fetching data similar to sample data fields plus help me.
  Thanks</p>