pouchdb-hoodie-unsynced-local-docs
v1.0.0
Published
Hoodie-like check for locally changed docs API for PouchDB
Downloads
3
Readme
pouchdb-hoodie-unsynced-local-docs
This PouchDB plugin provides simple methods to check if local DB has unsynced changes.
Usage
// Initialisation
var db = new PouchDB('dbname')
var api = db.unsyncedLocalDocs({remote: 'http://example.com/mydb'})
api.unsyncedLocalDocs()
.then(function(changes) {
// changes is array of docs?
})
api.unsyncedLocalDocs('docid') // pass doc id
api.unsyncedLocalDocs({_id: 'docid'}) // pass doc with _id property
api.unsyncedLocalDocs(['docid', {_id: 'docid'}]) // array of IDs and objects
Approach
- we know localDb, but not the state of remoteDB when we are offline
- update_seq(for localDb/remoteDb) + get
_local/
ids for both, 1-time replication & continuous replication* - localDb/_changes?since=
- if it returns anything: there are changes
hint:
https://github.com/pouchdb/pouchdb/blob/master/lib/replicate/genReplicationId.js
Installation
With browserify or on node.js/io.js
Attach this plugin to the PouchDB object:
npm install --save pouchdb
npm install --save pouchdb-hoodie-unsynced-local-docs
Install via npm
var PouchDB = require('pouchdb')
PouchDB.plugin(require('pouchdb-hoodie-unsynced-local-docs'))
Contributing
Have a look at the Hoodie project's contribution guidelines. If you want to hang out you can join #hoodie-pouch on our Hoodie Community Slack.