Using a prior example? How could I insert/update a mysql table using
a JSON object without manually naming the table column headers? And insure it async.
var mysql = require('node-mysql');
var conn = mysql.createConnection({
...
});
var values = [
{name:'demian', email: '[email protected]', ID: 1},
{name:'john' , email: '[email protected]' , ID: 2},
{name:'mark' , email: '[email protected]' , ID: 3},
{name:'pete ' , email: '[email protected]' , ID: 4}
];
// var sql = "INSERT INTO Test (name, email, n) VALUES ?";
conn.query(sql, [values], function(err) {
if (err) throw err;
conn.end();
})