pouchdb-live-query
v1.5.0
Published
PouchDB plugin which keeps a view live by listening to the changes feed.
Downloads
6
Readme
PouchDB Live Query Plugin
Provide a view which keeps itself up to date by listening to the changes feed.
:warning: Very alpha.
Installation
pouchdb-live-query is hosted on npm.
Node
Install via npm install pouchdb-live-query
var PouchDB = require('pouchdb')
PouchDB.plugin(require('pouchdb-live-query'))
Browser
Use the browserified build.
<script src="pouchdb.js"></script>
<script src="pouchdb-live-query.js"></script>
Usage
var db = new PouchDB('mydb')
db.liveQuery('my/view')
.then(function(result) {
// result is extended view query result
// { total_rows: 3, rows: [{ id: 'mydoc', key: ... }, ...] }
// event emitter
result.on('change', function(change) {
// result has been updated
})
// stop listening
result.cance()
})
db.liveQuery(fun, [options])
Similar to db.query
.
Options
fun
: The name of a view in an existing design document, e.g.'mydesigndoc/myview'
.options.include_docs
: Include the document in each row in the doc field.options.descending
: Reverse the order of the output rows.options.startkey
andoptions.endkey
: Return only rows between these.
Whats Missing
callback
- Currently works only with promises.options.key
- Key exact match is ignored on view update.options.reduce
- No reduce support at all. Just to mention some...
Tests
npm test