Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mongodb inserts
var mongodb = require('mongodb');
var server = new mongodb.Server('127.0.0.1', 27017, { auto_reconnect: false });
var db = new mongodb.Db('tester', server, { native_parser: true });
var insertCount = 0;
db.open(ready);
function ready(err, db) {
process.nextTick(function () {
db.collection('statuses', function (err, coll) {
coll.insert({ 'yooo': 'dude' }, function (err, result) {
if (!err) {
insertCount += 1;
}
});
});
ready(null, db);
});
}
setInterval(function () {
console.log(insertCount);
insertCount = 0;
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment