pouchdb-upsert-bulk
v1.0.2
Published
Upsert bulk plugin for PouchDB
Downloads
18
Readme
pouchdb-upsert-bulk
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
- Browser support
- pouchdb-upsert-like diff functions
Author
© 2016 Tom Vincent [email protected] (https://tlvince.com)
License
Released under the MIT license.