I am developing a web app using nodejs and mysql. The mysql connection is working as fine but query is not excecuting and not showing any errors. My code ishown below. Pls help me.
var mysql = require("mysql");
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database : "db"
});
con.connect(function(err){
if(err){
        console.log('Error connecting to Db');
    return;
} else {
var time = Date.now();
var post  = {userphone: "user", senderphone: "to1", message: "msg", time:time};             
var query = con.query('INSERT INTO chat SET ?', post, function(err, result) {
    console.log('db added');
    console.log(query.sql);
            });
        console.log('Connection established');
    }
});
con.end(function(err) {
    // The connection is terminated gracefully
    // Ensures all previously enqueued queries are still
    // before sending a COM_QUIT packet to the MySQL server.
});
INSERT INTO table (field1, field2) VALUES (value1, value2)