如何使用mysljs批量插入mySql和node.js

Iva*_*žić 8 mysql node.js bluebird

我无法使用node.js lib mysljs在我的数据库中使用批量插入.

我按照以下答案:

如何使用node.js在mySQL中进行批量插入

没有成功.

var sql = "INSERT INTO resources (resource_container_id, name, title, extension, mime_type, size) VALUES ?";

var values = [
  [1, 'pic1', 'title1', '.png', 'image/png', 500], 
  [1, 'pic2', 'title2', '.png', 'image/png', 700]];

return connection.query(sql, [values], (result) => {
    if (err) throw err;
    connection.end();
});
Run Code Online (Sandbox Code Playgroud)

我一直收到错误:

 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'?\' at line 1' 
Run Code Online (Sandbox Code Playgroud)

我也尝试使用蓝鸟宣传查询方法,但没有成功,我再次得到同样的错误.

小智 -2

尝试删除周围的方括号values