pouchdb-upsert-bulk

1.0.2 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i pouchdb-upsert-bulk

Weekly Downloads

17

Version

1.0.2

License

MIT

Last publish

Collaborators

  • tlvince