CouchStream
A Stream interface for couchdb.
example
basically just point CouchStream at your couch server ande start spraying documents in!
create a CouchStream and start writing documents to it.
has the same interface as Stream
var CouchStream =var save = CouchStreamsave
or even better: USE PIPE
documentSource
all the following examples use EventStream
a toolkit for working creating and using Streams.
common options
each CouchStream function takes options and returns a stream.
the following options apply to all functions:
database: database // database (mandatory)port: port // port (default: 5984)host: host // host (default: 'localhost')url:'http://HOST:PORT/DB' //optional, in place of using database, host, & port
changes (opts)
read changes from the database, as they occur.
wraps Follow
so options that work for follow, will work the same here.
var opts =since: seq // sequence number to listen from (default: 'now')include_docs: boolean // emit docs at each change (default: false)filter: filter // a path to a design doc or a filter function (default: null (do not filter))//plus optionsCouchStream
save (opts)
Save a stream of documents to the database,
wraps request
so options that work for request will also work here.
requires only the common options.
readable
get (opts)
retrive the docs from a Stream of ids.
must be stream of strings, or objects with _id
or id
properties.
requires only the common options.
ids
wait (opts)
buffer the stream until the database exists, (makes sense ahead of save)
no documents will be let through until the database has exists.
does not create the database.
var waitForExists =CouchStreamvar es =es
create
create a database, buffering the stream until the database is ready.
(makes sense ahead of save)
var createDB =CouchStreamvar es =es
TODO
view
(pull sections at a time respecting pause, etc)
delete
delete documents from a stream of ids (similar to get).