There was an error while loading. Please reload this page.
Generates SQL command for INSERT INTO.
sql.insertInto(table, values, [options]); sql.insertInto.stream(table, stream, [options]); // table: table name // values: row objects {column: value} // stream: readable stream with row objects {column: value} // options: options {pk} // .pk: primary key, on conflict (null => none)
const sql = require('extra-sql'); sql.insertInto('food', [{code: 'F1', name: 'Mango'}], par); // INSERT INTO "food" ("code", "name") VALUES\n($$F1$$, $$Mango$$); sql.insertInto('food', [{code: 'F1', name: 'Mango'}, {code: 'F2', name: 'Lychee'}], {pk: 'code'}); // INSERT INTO "food" ("code", "name") VALUES // ($$F1$$, $$Mango$$), // ($$F2$$, $$Lychee$$) // ON CONFLICT ("code") DO NOTHING;