1.0.2 • Published 7 years ago

pouchdb-upsert-bulk v1.0.2

Weekly downloads
40
License
MIT
Repository
github
Last release
7 years ago

pouchdb-upsert-bulk

Build Status npm version License

Upsert bulk plugin for PouchDB

db.allDocs({include_docs: true})
//=> {rows: [{doc: {_id: '1', _rev: '1', prop: 'foo', other: true}}]}

// Merge
db.upsertBulk([{_id: '1', prop: 'bar'}])
  .then(() => db.allDocs({include_docs: true}))
  //=> {rows: [{doc: {_id: '1', _rev: '2', prop: 'bar', other: true}}]}

// Replace
db.upsertBulk([{_id: '1', prop: 'bar'}], {replace: true})
  .then(() => db.allDocs({include_docs: true}))
  //=> {rows: [{doc: {_id: '1', _rev: '3', prop: 'bar'}}]}

Note only tested in Node >=6.

Usage

npm install --save pouchdb-upsert-bulk
import PouchDB from 'pouchdb'
import upsertBulk from 'pouchdb-upsert-bulk'

PouchDB.plugin(upsertBulk)

API

upsertBulk(<docs> [, opts])

Perform a bulk upsert (update or insert) operation. Inserts new docs. Merges existing docs.

  • opts.replace: replaces existing docs

Future work

Author

© 2016 Tom Vincent git@tlvince.com (https://tlvince.com)

License

Released under the MIT license.

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago