Package Exports
- knex-upsert2
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (knex-upsert2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
knex-upsert2
An upsert function for knex. A fork of knex-upsert with support for mysql
Installation
npm install knex-upsert2 --save
Usage
const knex = require('knex')
const upsert = require('knex-upsert2')
const db = knex({
dialect: 'sqlite3', //or mysql
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',
}).then(res=>{
//callback
}).catch(err=>{
//error handling
})