1.2.0 • Published 7 years ago

ouch-stream v1.2.0

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

Ouch Stream Build Status

Library wrapping PouchDB with object streams.

Usage

To use Ouch Stream one have to wrap database object with Ouch instance and then use its methods to create Readable and Writable streams.

var Ouch = require('ouch-stream');
var ouch = new Ouch(db);
ouch.all().pipe(transform).pipe(ouch.sink())

Reference

Constructor

Wraps single pouchdb database.

new Ouch(db)
ArgumentDescription
dbA PouchDB database

Methods

all

Returns readable stream of all documents.

ouch.all(options)
ArgumentDescription
optionsAn options object passed to db.all_docs. The following fields are not passed: include_docs, skip, limit, startkey

view

Returns readable stream of view results.

ouch.view(name,options)
ArgumentDescription
nameA view name
optionsAn options object passed to db.query. The following fields are not passed: skip, limit, startkey. The default pagination is using startkey for performance reason, setting limit_skip switches to use growing skip value.

To use this method the db object must support query method.

sink

Returns writable stream 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.sink()

merge

Returns writable stream 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.merge(mergeFunction)    
ArgumentDescription
mergeFunctionA merge function (object,current) => document to store
1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago