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.


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’, ‘’],

[‘Admin’, ‘’],


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

if (err) throw err;