Skip to content

Instantly share code, notes, and snippets.

@tommedema
Created March 9, 2012 19:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
//opens the stats collection
var openStats = function(err, stats) {
if (err) return console.log('error opening stats %o', err);
//when a new request occurs
stats.update({name: 'reqcount'}, {'$inc': {value: 1}}, {safe: true}, function() { });
};
//opens the database
var db = new Db('musictv', replSet);
db.open(function(err) {
console.log('database opened');
if (err) return console.log('database error %o', err);
db.collection('stats', openStats);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment