You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
782 B

5 years ago
const mysql = require('mysql')
const config = require('./../../config.js')
const dbConfig = config.database
const pool = mysql.createPool({
host : dbConfig.HOST,
user : dbConfig.USERNAME,
password : dbConfig.PASSWORD,
database : dbConfig.DATABASE
})
let query = function( sql, values ) {
return new Promise(( resolve, reject ) => {
pool.getConnection(function(err, connection) {
if (err) {
console.log( err )
resolve( err )
} else {
connection.query(sql, values, ( err, rows) => {
if ( err ) {
console.log( err )
reject( err )
} else {
resolve( rows )
}
connection.release()
})
}
})
})
}
module.exports = {
query
}