I want to insert each element from an array as the rows of a column.
Example:
array = [1,2,3,2];
the result will be:
column1 |
---------
1 |
2 |
3 |
2 |
I tried out the following code below in my Node.js file but it doesn't seem to work.
var array = [1,2,3,2];
var queryString = "INSERT INTO table (column1) VALUES ((${array.map((v,i) => `${i+1}`).join(',')}) RETURNING *";
db.query(queryString, array, (err, result) => {
if (err) throw err;
});