Skip to content

pbrandt1/sqlite3-upsert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sqlite3-upsert

simple module to allow you to use upsert, basically the only thing worth having.

upsert(options) returns function(object, [callback])

var upsert_product = upsert({table: 'products', key: 'id', db: db})
upsert_product({id: 'a', val: 'something'})

full example

var sqlite3 = require('sqlite3')
var upsert = require('sqlite3-upsert')
var db = new sqlite3.Database('test.db')
var upsert_product = upsert({table: 'products', key: 'id', db: db})
db.serialize(function() {
  db.run('create table products (id text, val text)')
  upsert_product({id: 'a'}, console.log.bind(console))
  upsert_product({id: 'a', val: 'asdfasdf'}, console.log.bind(console))
})

ISC License

Copyright (c) 2016, Peter Brandt

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

About

upserts for the node sqlite3 module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published