Skip to content

Commit

Permalink
Added README.md and updated package description.
Browse files Browse the repository at this point in the history
  • Loading branch information
AGrzes committed May 29, 2017
1 parent 8e2469f commit 5c2e177
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Ouch Stream [![Build Status](https://travis-ci.org/AGrzes/ouch-stream.svg?branch=master)](https://travis-ci.org/AGrzes/ouch-stream)
Library wrapping [PouchDB](https://pouchdb.com/) with object streams.

## Usage
To use Ouch Stream one have to wrapp 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)

|Argument| Description|
|---|---|
| db | A PouchDB database |

### Methods
#### all
Returns readable stream of all documents.

ouch.all(options)

|Argument| Description|
|---|---|
| options | An 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)

|Argument| Description|
|---|---|
| name | A view name |
| options | An options object passed to db.query. The following fields are not passed: `skip`, `limit`, `startkey` |

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

#### sink
Returns writable stream that writes incomming objects into db.

The operation will fail on any error so it is usefull for inserting completly new documents and for updating documents previously fetched from db (so current `_rev` is known).

ouch.sink()

#### merge
Returns writable stream that writes incomming 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)

|Argument| Description|
|---|---|
| mergeFunction | A mrege function `(object,current) => document to store` |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ouch-stream",
"version": "0.0.1",
"description": "Library wrapping pouchdb with object streams.",
"description": "Library wrapping PouchDB with object streams.",
"main": "index.js",
"scripts": {},
"repository": {
Expand Down

1 comment on commit 5c2e177

@AGrzes
Copy link
Owner Author

@AGrzes AGrzes commented on 5c2e177 May 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolves #3

Please sign in to comment.