I have an object item like below
var item = {"9":"9","22":"22","23":"23","24":"24"};
and variables var cart = 23;
and var group = 40;
Now I want to form those items in a format such that I can perform multi-row MySQL insert like below
var sql = "INSERT INTO test (item, cart, group) VALUES ?";
var values = [
[9, 23, 40],
[22, 23, 40],
[23, 23, 40],
[24, 23, 40]
];
I need to form the above array format to perform multi rows insert in node js. How to make the above format?
via SO-user
No comments:
Post a Comment