Here myObject is an object and I want to update my table depending upon the number of keys myObject contains. The number of keys in myObject can be dynamic how do I update the table in that case?
var myObject ={
x1 : 0,
x2 :1
}
var stmt =""UPDATE tb_data SET x1 = ?, x2 = ?....xn =?";
Try using Object.keys(myObject).forEach to loop through each of your objects, building up the string you need each time.
var myObject ={
x1 : 0,
x2 :1
}
var stmnt = '';
Object.keys(myObject).forEach((val) => {
stmnt += val;
})