Created
February 4, 2013 21:17
-
-
Save groundwater/4709805 to your computer and use it in GitHub Desktop.
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
function Database(mysql,config){ | |
this.mysql = mysql; | |
this.config = config; | |
// setup mysql connection based on config | |
} | |
Database.prototype.get = function(){ | |
// return an open mysql handle | |
// if mysql has re-connected, make sure | |
// you're returning the active connection | |
} | |
module.exports.inject = function(di){ | |
return new Database(di.mysql,di.config); | |
} |
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 di = {}; | |
di.config = require('./config'); | |
// pass in the actual mysql library | |
di.mysql = require('mysql'); | |
// setup your database | |
di.database = require('./database').inject(di); | |
// your app will have a fully connected database | |
di.app = require('./app').inject(di); |
@diogogmt I have a draft here
https://gist.github.com/jacobgroundwater/ae7d6a4af43b71fed82a
I would appreciate any feedback you have. I'll publish to my blog later, once I get polish it up.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking forward to that blog post :)