salix/print/core/database.js

21 lines
465 B
JavaScript

const mysql = require('mysql2/promise');
const config = require('./config.js');
module.exports = {
init() {
if (!this.pool)
this.pool = mysql.createPool(config.mysql);
},
find(query, params) {
return this.pool.query(query, params).then(([rows]) => {
return rows;
});
},
findOne(query, params) {
return this.find(query, params).then(([rows]) => rows);
},
findFromDef() {
}
};