title: Mongoose - Insert two collections : one is ID dependant of the other
body: <p>I have an array of objects I want insert in my DB:</p>
  
  <pre><code>        tracks = [new Track({name : "myname1"}), new Track({name : "myname2"})]
  
          Track.collection.insert(tracks, {}, function(err, tracks){   
               console.log('err', err);
          }
  </code></pre>
  
  <p>But even with 2 objects in the array, the insert() method throw an error : </p>
  
  <pre><code>[RangeError: Maximum call stack size exceeded]
  </code></pre>
  
  <p>(The "tracks" doc is created, but nothing inside it.)</p>
  
  <p><strong>EDIT</strong> 
  <a href="https://stackoverflow.com/questions/24466366/mongoose-rangeerror-maximum-call-stack-size-exceeded">Mongoose - RangeError: Maximum Call Stack Size Exceeded</a> solve the first problem but not solve my real problem:</p>
  
  <p>When you create an object from a Model, you can get the _id, which I use to create an other object. But is not possible to insert a collection of Mongoose object, as the solved question: <strong>You have to use an array JSON object ONLY</strong>.</p>
  
  <pre><code>data.items.forEach(function(item,index){
      tracks.push(new Track({name : "myname1"}) );
      posts.push(new Post({trackId : track._id}) );
  }
  
  Track.collection.insert(tracks, {}, function(err, tracks){   
           console.log('err', err);
      }
  </code></pre>