Skip to content

Instantly share code, notes, and snippets.

@matomesc
Created March 5, 2012 05:06
Show Gist options
  • Save matomesc/1976703 to your computer and use it in GitHub Desktop.
Save matomesc/1976703 to your computer and use it in GitHub Desktop.
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