33 lines
No EOL
675 B
JavaScript
33 lines
No EOL
675 B
JavaScript
module.exports = {
|
|
query: async function (db, sql) {
|
|
return new Promise((resolve, reject) => {
|
|
db.query(sql, async (error, results) => {
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
if (results.length > 0) {
|
|
resolve(results[0]);
|
|
} else {
|
|
resolve(false);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
|
|
queryMulti: async function (db, sql) {
|
|
return new Promise((resolve, reject) => {
|
|
db.query(sql, async (error, results) => {
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
if (results.length > 0) {
|
|
resolve(results);
|
|
} else {
|
|
resolve(false);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}; |