P粉5452181852023-09-05 18:56:24
Thanks to Fredrik, I fixed it. I ended up using the following promise
let promiseQuery = await new Promise((resolve, reject) => { con.query(`SOME SQL QUERY`, (error, results, fields) => { if (error) reject(error); resolve(results || {}); }) }) const someVar = promiseQuery.length if (someVar === 0) { // Some code } else { // Some code }