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', 'demian@gmail.com', 1],
['john', 'john@gmail.com', 2],
['mark', 'mark@gmail.com', 3],
['pete', 'pete@gmail.com', 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?