Skip to content

Instantly share code, notes, and snippets.

@scarvell
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save scarvell/9199787 to your computer and use it in GitHub Desktop.

Select an option

Save scarvell/9199787 to your computer and use it in GitHub Desktop.
var mysql = require('mysql');
var dbConfig = {
host: '',
user: '',
pwd: '',
db: ''
};
pool = mysql.createPool({
host : dbConfig.host,
user : dbConfig.user,
password : dbConfig.pwd,
database : dbConfig.db
});
exports.query = function () {
var args = arguments;
pool.getConnection(function(err, conn){
args.forEach(function (argument, index) {
if (typeof argument === 'function') {
args[index] = function () {
argument(arguments);
conn.release();
};
}
});
conn.query.apply(conn, args);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment