Skip to content

Instantly share code, notes, and snippets.

@r01010010
Created November 25, 2014 03:05
Show Gist options
  • Save r01010010/af8eeb39023ce1cc04f6 to your computer and use it in GitHub Desktop.
Save r01010010/af8eeb39023ce1cc04f6 to your computer and use it in GitHub Desktop.
var server = new mongodb.Server('localhost', 27017, {auto_reconnect: true, safe: true});
var db = new mongodb.Db('scjs', server);
db.open(function(err, db) { if(err) throw err;
async.eachSeries(
// Collection
mongo_provinces
// Iterator
, function(province, done){
db.collection('provinces').insert(province, function(err, result) { if(err) throw err;
console.log(result);
done();
});
}
// Callback when the iteration is finished
, function(err){ if(err) throw err;
process.exit();
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment