I have some Node.js code that tries to update a database in something like the following:
connection.query(command, function(err,rows) {
if (err){
If @Sridhar answer doesn't work for you, probably because you are using promise API which doesn't yet return the SQL query, you can use:
const sql = connection.format("SELECT * FROM table WHERE foo = ?", ["bar"]);
console.log(sql);
const [rows] = await connection.query(sql);
Documentation: https://github.com/mysqljs/mysql#preparing-queries