Discord_API_Bot/helpers/helper.js

33 lines
675 B
JavaScript
Raw Normal View History

2024-04-02 04:02:22 +01:00
module.exports = {
2024-04-08 11:12:41 +01:00
query: async function (db, sql) {
return new Promise((resolve, reject) => {
db.query(sql, async (error, results) => {
if (error) {
throw error;
2024-04-02 04:02:22 +01:00
}
2024-04-08 11:12:41 +01:00
if (results.length > 0) {
resolve(results[0]);
2024-04-02 04:02:22 +01:00
} else {
2024-04-08 11:12:41 +01:00
resolve(false);
2024-04-02 04:02:22 +01:00
}
});
});
},
2024-04-08 11:12:41 +01:00
queryMulti: async function (db, sql) {
return new Promise((resolve, reject) => {
db.query(sql, async (error, results) => {
if (error) {
throw error;
2024-04-02 04:02:22 +01:00
}
2024-04-08 11:12:41 +01:00
if (results.length > 0) {
resolve(results);
2024-04-02 04:02:22 +01:00
} else {
2024-04-08 11:12:41 +01:00
resolve(false);
2024-04-02 04:02:22 +01:00
}
});
});
}
2024-04-08 11:12:41 +01:00
};