I am having trouble with inserting data into my database on Heroku (MySQL, ClearDB). Whenever I am trying to execute INSERT query it just does not work, nothing is inserted, no error messages at all. SELECT query works fine and I confirmed that but no idea what am I doing wrong in this case. Please find a snippet below: So this is my INSERT function:
getUserDetails(value, (err, result)=>{
if(err){
return;
}
if(result.length > 0){
socket.emit("verify", {type: true, message: "Username taken"});
}else{
const connSocket = getDbConnectionSocket();
connSocket.connect(err=>{
if (err){
return;
}
const sql="INSERT INTO tableName (column1, column2, column3) VALUES ?";
const values = [value.key1,value.key2, "value2AsString"];
connSocket.query(sql, [values], (err, result)=>{
if(err){
return;
}
});
connSocket.end();
});
}
})
and this is my getUserDetails function:
function getUserDetails(value, callback){
const connSocket = getDbConnectionSocket();
connSocket.connect(err=>{
if (err){
return;
}
connSocket.query(`SELECT * FROM table WHERE column="${value.key1}"`, callback);
connSocket.end();
});
}
DB Config is 100% correct, SELECT requests are working, socket.io is working perfectly fine. I am sending this request from the index.js file which is now hosted on my localhost and is an http server. This in the future will be as well hosted on heroku.
Can anyone explain me what is going on here and how to fix it? I would be grateful for correct explanation on the problem.