title: How to Bulk update or Upsert in mongodb with nodejs?
body: <p>I need to update 3000+ bulk records in a collection by using mongoDB bulk update method, but It is inserting single records at a time.</p>
  
  <p>I need to insert as a bulk. kindly suggest better way</p>
  
  <pre><code>     function bulkGl(DataArray){
    var bulk = Transaction.collection.initializeUnorderedBulkOp();
    for(i in DataArray){
      if(typeof DataArray[i].convertedValue !== NaN){
        var Data =  { "currency_conversions":[{
          "converted_value" : DataArray[i].convertedValue
         }]};
         var query =  { testid : DataArray[i].testid};
         bulk.find(query).upsert().update( Data)
    console.log('statusdata',Data);
    }
  }
  bulk.execute(function(err,res){
    console.log(err,data);
  });
  }
  </code></pre>