Node.js/MySQL: Printing actual query in error log in node.js

Source: https://stackoverflow.com/questions/41169797/node-js-mysql-printing-actual-query-in-error-log-in-node-js



As per docs, You can use query.sql to get the actual executed query.
var post  = {id: 1, title: 'Hello MySQL'};
var query = connection.query('INSERT INTO posts SET ?', post, function(err, result) {
  // Neat!
});
console.log(query.sql); // INSERT INTO posts SET `id` = 1, `title` = 'Hello MySQL'
In this case, it will be
connection.query(command, function (err, rows) {
    if (err) {
        console.log('this.sql', this.sql); //command/query
        console.log(command);
        console.log("ERROR");
        console.log(err);
        return;
    }
    console.log("good");
});

Không có nhận xét nào:

Cold Turkey Blocker

 https://superuser.com/questions/1366153/how-to-get-rid-of-cold-turkey-website-blocker-get-around-the-block Very old question, but still wan...