Skip to content

Instantly share code, notes, and snippets.

@t-2013
Created February 27, 2013 20:16
Show Gist options
  • Save t-2013/5051294 to your computer and use it in GitHub Desktop.
Save t-2013/5051294 to your computer and use it in GitHub Desktop.
//Array of trip objects
var trips = [];
db.trips.drop();
db.trips = db.collection('trips');
var counter = 0;
for(var i = 0; i < trips.length; i++){
db.trips.save(trips[i], function(err){
if(!err){
counter += 1;
if(counter == trips.length){
// All objects saved
res.end('Db initialized');
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment