title: Inserting a big array of object in mongodb from nodejs
body: <p>I need to insert a big array of objects (about 1.5-2 millions) in mongodb from nodejs. How can i improve my inserting?</p>
  
  <p>This is my code:</p>
  
  <pre><code>var sizeOfArray = arrayOfObjects.length; //sizeOfArray about 1.5-2 millions
  for(var i = 0; i &lt; sizeOfResult; ++i) {
    newKey = {
      field_1: result[i][1],
      field_2: result[i][2],
      field_3: result[i][3]
    };
    collection.insert(newKey, function(err, data) {
      if (err) {
        log.error('Error insert: ' + err);
      }
    });
  }
  </code></pre>