Skip to content

Instantly share code, notes, and snippets.

@tommedema
Created March 9, 2012 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommedema/2008348 to your computer and use it in GitHub Desktop.
Save tommedema/2008348 to your computer and use it in GitHub Desktop.
//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