Module couchdb_changes

Function Index

cancel_stream/1
follow/1
follow/2Stream changes to a pid.
follow_once/1
follow_once/2fetch all changes at once using a normal or longpoll connections.
stream_next/1

Function Details

cancel_stream/1

cancel_stream(Ref) -> any()

follow/1

follow(Db::db()) -> {ok, StreamRef::atom()} | {error, term()}

follow/2

follow(Db::db(), Options::changes_options()) -> {ok, StreamRef::atom()} | {error, term()}

Stream changes to a pid

Db : a db record

Client : pid or callback where to send changes events where events are The pid receive these events:

{change, StartRef, {done, Lastseq::integer()}
Connection terminated or you got all changes
{change, StartRef, Row :: ejson_object()}
Line of change
{error, LastSeq::integer(), Msg::term()}
Got an error, connection is closed when an error happend.
LastSeq is the last sequence of changes.

While the callbac could be like:
       fun({done, LastSeq}) ->
           ok;
       fun({done, LastSeq}) ->
           ok;
       fun({done, LastSeq}) ->
           ok.

>Options :: changes_stream_options() [continuous
     | longpoll
     | normal
     | include_docs
     | {since, integer() | now}
     | {timeout, integer()}
     | heartbeat | {heartbeat, integer()}
     | {filter, string()} | {filter, string(), list({string(), string() | integer()})}
     | {view, string()},
     | {docids, list))},
     | {stream_to, pid()},
     | {async, once | normal}]

Return {ok, StartRef, ChangesPid} or {error, Error}. Ref can be used to disctint all changes from this pid. ChangesPid is the pid of the changes loop process. Can be used to monitor it or kill it when needed.

follow_once/1

follow_once(Db::db()) -> {ok, LastSeq::integer(), Changes::list()} | {error, term()}

follow_once/2

follow_once(Db::db(), Options::changes_options()) -> {ok, LastSeq::integer(), Changes::list()} | {error, term()}

fetch all changes at once using a normal or longpoll connections.

Db : a db record

Options :: changes_options() [
     | longpoll
     | normal
     | include_docs
     | {since, integer() | now}
     | {timeout, integer()}
     | heartbeat | {heartbeat, integer()}
     | {filter, string()}
     | {filter, string(), list({string(), string() | integer()})}
     | {docids, list()))},
     | {stream_to, pid()}
     ]

Result: {ok, LastSeq::integer(), Rows::list()} or {error, LastSeq, Error}. LastSeq is the last sequence of changes.

stream_next/1

stream_next(Ref) -> any()


Generated by EDoc