# bookshelf-upsert

> A bookshelf plugin for performing upserts

Latest version **0.2.0** (published 2018-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install bookshelf-upsert
pnpm add bookshelf-upsert
yarn add bookshelf-upsert
bun add bookshelf-upsert
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-03-03 |
| First published | 2017-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Paul Anderson |
| Maintainers | pandapaul |
| Keywords | 🐼, bookshelf, upsert |

## Links

- npm: https://www.npmjs.com/package/bookshelf-upsert
- Repository: https://github.com/pandapaul/bookshelf-upsert
- Homepage: https://github.com/pandapaul/bookshelf-upsert#readme
- Issues: https://github.com/pandapaul/bookshelf-upsert/issues
- npm.io page: https://npm.io/package/bookshelf-upsert

## Recent versions

- 0.2.0 (latest) — 2018-03-03
- 0.1.5 — 2018-01-25
- 0.1.4 — 2017-05-18
- 0.1.3 — 2017-05-17
- 0.1.2 — 2017-05-04
- 0.1.1 — 2017-05-04
- 0.1.0 — 2017-05-04

## README

# bookshelf-upsert

> A [Bookshelf](http://www.bookshelfjs.org/) plugin that adds `model.upsert()`

[![Build Status](https://travis-ci.org/pandapaul/bookshelf-upsert.svg?branch=master)](https://travis-ci.org/pandapaul/bookshelf-upsert)

## Install

```
$ npm install --save bookshelf-upsert
```


## Plugging In

```js
const upsert = require('bookshelf-upsert')

bookshelf.plugin(upsert)
```


## Usage

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

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


## API

### model.upsert([attributes], [options])

Bookshelf model instances are provided the `upsert` method, which may be given attributes and options that will be 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

---
_Source: https://npm.io/package/bookshelf-upsert · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
