
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
knex-on-duplicate-update
Advanced tools
Simple patcher for Knex. It adds the .onDuplicateUpdate() function to knex's query builder.
Simple patcher for Knex. It adds the .onDuplicateUpdate() function to knex's query builder in order to add support MySQL's on duplicate key update columnName=Values(columnName)
.
Knex
(v0.21.10) added an official upsert
functionality with similar capabilities which supports MySQL, Postgress & SQLite.
To use this lib, first you will have to install it:
npm i knex-on-duplicate-update --save
or
yarn add knex-on-duplicate-update
Then, add the following lines to your Knex set up:
const knex = require('knex')(config);
const {attachOnDuplicateUpdate} = require('knex-on-duplicate-update');
attachOnDuplicateUpdate();
onDuplicateUpdate(...columns: Array<{[key: string]: string} | string>): Knex.QueryBuilder
await knex.insert({id: 1, name: 'John', email: 'john@mail.com'})
.into('persons')
.onDuplicateUpdate('name', 'email');
Setting a fallback value for a column
await knex.insert({id: 1, name: 'John', email: 'john@mail.com'})
.into('persons')
.onDuplicateUpdate('name', {email: 'john-exists@mail.com'});
This lib got inspiration from knex-paginator
.
FAQs
Simple patcher for Knex. It adds the .onDuplicateUpdate() function to knex's query builder.
The npm package knex-on-duplicate-update receives a total of 315 weekly downloads. As such, knex-on-duplicate-update popularity was classified as not popular.
We found that knex-on-duplicate-update demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.