var mysql = require('mysql');
var pool  = mysql.createPool({
    connectionLimit : 10,
    host            : process.env.DB_HOST,
    user            : process.env.DB_USERNAME,
    password        : process.env.DB_PASSWORD,
    database        : process.env.DB_DATABASE
});

var asyncPool = function(q,v){
    return new Promise((r,j)=>{
        v = v || [];
        pool.query(q, v, function (error, results, fields) {
            if (error) return j(error);
            r(results);
        });
    });
}
module.exports = asyncPool;