Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

knex-upsert

ratson1.3kMIT0.0.4

An upsert function for knex.

knex, upsert

readme

knex-upsert

An upsert function for knex.

Installation

npm install knex-upsert --save

Usage

const knex = require('knex')
const upsert = require('knex-upsert')

const db = knex({
  dialect: 'sqlite3',
  connection: { filename: './data.db' }
})
db.schema.createTable('users', table => {
  table.increments('id')
  table.string('user_name')
})

upsert({
  db,
  table: 'users',
  object: { id: 1, user_name: 'happy-user' },
  key: 'id',
})