Skip to content

Instantly share code, notes, and snippets.

@kohlikohl
Created March 28, 2013 09:54
Show Gist options
  • Save kohlikohl/5262056 to your computer and use it in GitHub Desktop.
Save kohlikohl/5262056 to your computer and use it in GitHub Desktop.
Improvement?
var Mysql = module.exports = function (conf) {
var poolConfig = {
name: 'mysql',
create: this._createConnection.bind(this),
destroy: this._destroyConnection,
max: 10
};
this._conf = conf;
this._pool = pool.Pool(poolConfig);
};
Mysql.prototype._createConnection = function (callback) {
var config = {
"hostname": this._conf.get("mysql:hostname"),
"user": this._conf.get("mysql:user"),
"password": this._conf.get("mysql:password"),
"database": this._conf.get("mysql:database")
};
new mysql.Database(config).connect(
function (error) {
if (error) {
callback(error, null);
} else {
callback(null, this);
}
}
);
};
Mysql.prototype._destroyConnection = function (client) {
if (client) {
client.disconnect();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment