mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 23:04:04 +00:00
Improve error handling of mysqlQuery and return row count as result
This commit is contained in:
parent
7330db3563
commit
f4ee5271af
1 changed files with 5 additions and 7 deletions
|
@ -335,15 +335,13 @@ exports.mysqlQuery = function (connectionString, query) {
|
|||
connection.query(query, (err, res) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
// Check if res is an array
|
||||
} else {
|
||||
if (Array.isArray(res)) {
|
||||
resolve("Rows: " + res.length);
|
||||
} else {
|
||||
resolve("No Error, but the result is not an array. Type: " + typeof res);
|
||||
}
|
||||
|
||||
}
|
||||
connection.destroy();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue