Skip to content

ihordiachenko/bookshelf-upsert

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bookshelf-upsert

A Bookshelf plugin that adds model.upsert()

Build Status

Install

$ npm install --save bookshelf-upsert

Plugging In

const upsert = require('bookshelf-upsert')

bookshelf.plugin(upsert)

Usage

const model = require('a-bookshelf-model')

model.forge({ some: 'data' })
.where({ optional: 'constraint' })
.upsert({ optional: 'attributes' })

API

model.upsert([attributes])

Bookshelf model instances are provided the upsert method, which may optionally be given attributes to save. The attributes are simply passed along to model.save(). This implementation of upsert first attempts an update then if no rows are updated it follows up with an insert.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%