Mongoose - Insert two collections : one is ID dependant of the other Mongoose - Insert two collections : one is ID dependant of the other mongoose mongoose

Mongoose - Insert two collections : one is ID dependant of the other


The solution I found is to create my own unique Id rather to get the ID of a mongoose Object ...and use a JSON object:

data.items.forEach(function(item,index){    tracks.push({name : "myname1"}) ); //name is unique    posts.push({trackId : track.name) );}Track.create(tracks, function(err){            console.log('err', err);}