sql.query("SELECT * FROM users");
sql.query("SELECT * FROM users", (err, res) => {resolve(res)});
async getAll(_sql) {
let conn;
try {
conn = await this.pool.getConnection();
return await conn.query(_sql);
} catch (err) {
throw Error(err);
} finally {
if (conn) {
await conn.release();
}
}
}
getAll("SELECT * FROM users").then(rows => {
if (rows.length) {
return rows[0];
} else {
return null;
}
})