I have arrays stacked in 1 array and I would like to insert each array per column in MySQL.
I have reached to insert all data in arrays to 1 column, but I want to insert an array per column.
Please see the screenshot and code below.
con.connect(async(err)=>{
const x = await getStock()
if(err){
console.log(err);
return err;
}else{
console.log("DB ok");
}
console.log("connected");
x.filter(item=>item===undefined?false:true).map(item=>item.forEach(item=>{
const sql ="INSERT INTO test (testCol1) VALUES ?";
const values=[
[item]
];
con.query(sql,[values],(err,result)=>{
if(err)throw err;
console.log("this have been recorded"+result);
});
}));
});