I'm new to Node.js and I've hit a roadblock I can't figure out. I'm trying to add an array to a SQL table using an INSERT INTO query.
Following the example [here][1] I see that I add a question mark as a placeholder for my values array, and the code takes care of the rest - but that doesn't seem to be working.
Here's the code:
var temp = [1,3,2];
conn2string= "INSERT INTO " + process.env.DB_TABLE + '(`0`, `1`, `2`) VALUES ? ';
let query = connection.query(conn2string, temp, function (err, result) { // this will insert in to data base //[vals2[0]]
And the resulting SQL connection string is:
'INSERT INTO test(`0`, `1`, `2`) VALUES 1 `
What I'm expecting Is:
'INSERT INTO test(`0`, `1`, `2`) VALUES (1, 3, 2); `
Any suggestions what I'm doing wrong?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…