node 封装db层
时间:2021-07-01 10:21:17
帮助过:3人阅读
db =
{};
var mysql = require(
‘mysql‘);
var pool =
mysql.createPool({
connectionLimit: 10,
host: ‘192.168.188.26‘,
user: ‘aaa‘,
password: ‘123456‘,
port: ‘3306‘,
database: ‘test‘,
});
db.query =
function (sql, callback) {
if (!
sql) {
callback();
return;
}
pool.query(sql, function (err, rows, fields) {
if (err) {
console.log(err);
callback(err, null);
return;
};
callback(null, rows, fields);
});
}
module.exports = db;
node 封装db层
标签:mysql user exp mys UI data turn require mod