Skip to content

Instantly share code, notes, and snippets.

View howethomas's full-sized avatar
💭
Currently pairing, sleeping or walking the dogs.

Thomas Howe howethomas

💭
Currently pairing, sleeping or walking the dogs.
View GitHub Profile
@afshinm
afshinm / mongodb-singleton.js
Created April 5, 2013 10:57
MongoDb singleton connection in NodeJs
var Db = require('mongodb').Db;
var Connection = require('mongodb').Connection;
var Server = require('mongodb').Server;
//the MongoDB connection
var connectionInstance;
module.exports = function(callback) {
//if already we have a connection, don't connect to database again
if (connectionInstance) {
callback(connectionInstance);