Library wrapping PouchDB with rxjs observables.
Usage
To use Ouch Rx one have to wrap database object with Ouch instance and then use its methods to create Observables and Observers.
const Ouch = ;const ouch = db;ouchall
Reference
Constructor
Wraps single pouchdb database.
db
Argument | Description |
---|---|
db | A PouchDB database |
Methods
all
Returns observable of all documents.
ouchalloptions
Argument | Description |
---|---|
options | An options object passed to db.all_docs. The following fields are not passed: include_docs |
changes
Returns observable of a change feed.
ouch
Argument | Description |
---|---|
options | An options object passed to db.changes. |
view
Returns observable of view results.
ouch
Argument | Description |
---|---|
name | A view name |
options | An options object passed to db.query. The following fields are not passed: include_docs |
To use this method the db object must support query method.
sink
Returns observer that writes incoming objects into db.
The operation will fail on any error so it is useful for inserting completely new documents and for updating documents previously fetched from db (so current _rev
is known).
ouch
merge
Returns observer that writes incoming objects into db.
The operation will call the merge function with incoming object to prepare document to store. The operation will call the merge function again with incoming object and current document state if conflict is encountered. It will then retry write with the result of merge function.
ouch
Argument | Description |
---|---|
mergeFunction | A merge function (object,current) => document to store |
Merge Functions
The following ready to use merge functions are provided
skip
- if document exist in database then skip updateoverride
- override document in database with new documentassign
- merge the existing and new document the way that uses new properties over existing but leave existing properties if new values are not provided. The merge is shallow, it considers only top level properties.