bulk-insert-query
v1.1.3
Published
This module is used to generate native Bulk INSERT Queries.
Downloads
25
Maintainers
Readme
bulk-insert-query
Dialects
- MySQL
Install
npm i -D bulk-insert-query
Usage
const GetBulkInsertQuery = require('bulk-insert-query')
GetBulkInsertQuery(tableName , columnNames , dataValues)
* tableName - string
* columnNames - Array of strings
* dataValues - Array of Objects with column and value as key value pairs
GetBulkInsertQuery('table_name', ['name', 'age'], [{ name: 'test_name1', age: 22 } , { name: 'test_name2', age: 23 }])
// => "INSERT INTO table_name (name,age) values ('test_name',26),('test_name',26)"
GetBulkInsertQuery('test_table', ['id', 'city'], [{ id: 1, city: 'Delhi' } , { id: 2 , city: 'Bangalore' }])
// => "INSERT INTO test_table (id,city) values (1,'Delhi'),(2,'Bangalore')"