pouchdb-ensure
1.0.0 • Public • Published pouchdb-ensure
A PouchDB plugin.
Creates a doc or updates it, but only when necessary.
Good to make sure a design doc is saved on the database at startup time, and that it is updated on the database whenever it is changed on the code.
Usage
npm install --save pouchdb-ensure
PouchDB.plugin(require('pouchdb-ensure'))
var db = new PouchDB('mydb')
db.ensure({
_id: 'a doc',
value: 'a value'
})
.then(doc => {
return db.ensure({_id: 'a doc', value: 'a value'})
})
.then(doc => {
return db.ensure({_id: 'a doc', value: 'other value'})
})
.then(doc => {
})
Package Sidebar
Install
Weekly Downloads