How to pass an array in insert query using node js?

The array of records can easily be bulk inserted into the node.js. Before insertion, you have to convert it into an array of arrays.

Example

var mysql = require(‘node-mysql’);

var conn = mysql.createConnection({

// your database connection

});

var sql = “INSERT INTO Test (name, email) VALUES ?”;

var values = [

[‘best interview question’, ‘info@bestinterviewquestion.com’],

[‘Admin’, ‘admin@bestinterviewquestion.com’],

];

conn.query(sql, [values], function(err) {

if (err) throw err;

conn.end();

});