Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 37 lines (31 sloc) 1.079 kb
6955d4e initial commit
Konstantin Käfer authored
1 Subscribes to CouchDB's change feed and emits the JSON objects.
2
3 ## Usage
4
5 ```javascript
6 new CouchStream({
7 database: 'recipes',
8 query: {
9 since: 50,
10 heartbeat: 10000,
11 filter: 'app/blueberries',
12 vegetarian: true
13 }
14 }).on('change', function(change) {
15 console.warn(change);
16 });
17 ```
18
19 All parameters except for `database` are optional. All unrecognized query parameters are passed along so that CouchDB filter functions can use them.
18421b4 add filter desigin document creation
Konstantin Käfer authored
20
21 You can also supply a filter as a plain JavaScript function. CouchStream will create a filter design document on the server and use that filter to retrieve the changes. Make sure that you don't reference any variables outside that function; they won't be available on the CouchDB server.
22
23 ```javascript
24 new CouchStream({
25 database: 'recipes',
26 query: {
27 since: 50,
28 filter: function(doc, req) {
29 return doc.type == 'recipe' &&
30 doc.ingredients.indexOf('Coconut') >= 0;
31 }
32 }
33 }).on('change', function(change) {
34 console.warn(change);
35 });
36 ```
Something went wrong with that request. Please try again.