knex-on-conflict-do-nothing
v1.0.0
Published
Knex extension to insert on conflict do nothing
Readme
knex-on-conflict-do-nothing
Knex & pg extension. It adds .onConflictDoNothing() function to knex's quiry builder to support on conflict do nothing by PostgreSQL.
How to set up
To use this lib, first you will have to install it:
npm i knex-on-conflict-do-nothing --saveor
yarn add knex-on-conflict-do-nothingThen, add the following lines to your Knex set up:
const knex = require("knex")(config);
const { attachOnConflictDoNothing } = require("knex-on-conflict-do-nothing");
attachOnConflictDoNothing();Function definition
onConflictDoNothing(): Knex.QueryBuilderHow to use
Example
await knex
.insert({ id: 1, name: "John", email: "[email protected]" })
.into("persons")
.onConflictDoNothing();This lib got inspiration from knex-on-duplicate-update.
