Skip to content

Instantly share code, notes, and snippets.

@alanhoff
Created May 31, 2014 18:17
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 alanhoff/bd15d854040c77eef74e to your computer and use it in GitHub Desktop.
Save alanhoff/bd15d854040c77eef74e to your computer and use it in GitHub Desktop.
var mongodb = require('mongodb');
var config = require(__dirname + '/../config/general.json');
var db = null;
mongodb.MongoClient.connect(config.mongodb, function(err, database) {
if(err)
throw err;
db = database;
process.emit('dbready');
});
function Functional(){
this.__defineGetter__('collection', function(){
return db.collection.bind(db);
});
}
module.exports = new Functional();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment