Created
March 5, 2012 05:06
-
-
Save matomesc/1976703 to your computer and use it in GitHub Desktop.
mongodb inserts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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