2019-01-22 08:55:35 +00:00
|
|
|
const mysql = require('mysql2/promise');
|
|
|
|
const config = require('./config.js');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
init() {
|
|
|
|
if (!this.pool)
|
|
|
|
this.pool = mysql.createPool(config.mysql);
|
|
|
|
},
|
2019-10-31 11:43:04 +00:00
|
|
|
find(query, params) {
|
2019-10-24 05:41:54 +00:00
|
|
|
return this.pool.query(query, params).then(([rows]) => {
|
2019-10-31 11:43:04 +00:00
|
|
|
return rows;
|
2019-10-24 05:41:54 +00:00
|
|
|
});
|
|
|
|
},
|
2019-10-31 11:43:04 +00:00
|
|
|
findOne(query, params) {
|
|
|
|
return this.find(query, params).then(([rows]) => rows);
|
|
|
|
},
|
2019-10-24 05:41:54 +00:00
|
|
|
findFromDef() {
|
|
|
|
|
|
|
|
}
|
2019-01-22 08:55:35 +00:00
|
|
|
};
|