我需要在mysql表中插入多行。我一直在使用invokethen,但是invokethen使用多个查询插入行。
INSERT INTO table_name (field1,field2) VALUES ("field1-value1","field2-value1");
INSERT INTO table_name (field1,field2) VALUES ("field1-value2","field2-value2");
INSERT INTO table_name (field1,field2) VALUES ("field1-value3","field2-value3");
我可以使用bookshelfjs(或knex querybuilder)通过单个查询插入多行吗?
INSERT INTO table_name (field1,field2) VALUES ("field1-value1","field2-value1"),
("field1-value2","field2-value2"),
("field1-value3","field2-value3");
1条答案
按热度按时间ulmd4ohb1#
通过传递要插入的对象数组: