This question answers 99% of what I am looking for... How do I do a bulk insert in mySQL using node.js
var sql = "INSERT INTO Test (name, email, n) VALUES ?";
var values = [
['demian', '[email protected]', 1],
['john', '[email protected]', 2],
['mark', '[email protected]', 3],
['pete', '[email protected]', 4]
];
conn.query(sql, [values], function(err) {
if (err) throw err;
conn.end();
});
If I want to pass an expression, such as NOW()
, how would I do that? If I pass it in the array, it would count as a string. Since VALUES
is a ?
that gets populated by the array, I can't easily inject an expression. Any ideas?