Module couchbeam_view

Function Index

all/1fetch all docs.
all/2fetch all docs.
count/1Equivalent to count(Db, all_docs, []).
count/2Equivalent to count(Db, ViewName, []).
count/3count number of doc in a view (or all docs).
fetch/1Equivalent to fetch(Db, all_docs, []).
fetch/2Equivalent to fetch(Db, ViewName, []).
fetch/3Collect view results.
first/1Equivalent to first(Db, all_docs, []).
first/2Equivalent to first(Db, ViewName, []).
first/3get first result of a view.
fold/4Equivalent to fold(Function, Acc, Db, ViewName, []).
fold/5call Function(Row, AccIn) on succesive row, starting with AccIn == Acc.
foreach/3Equivalent to foreach(Function, Db, ViewName, []).
foreach/4call Function(Row) on succesive row.
parse_view_options/1parse view options.
stream/2Equivalent to stream(Db, all_docs, Client, []).
stream/3Equivalent to stream(Db, ViewName, Client, []).
stream/4stream view results to a pid.
view_loop/2

Function Details

all/1

all(Db::db()) -> {ok, Rows::[ejson_object()]} | {error, term()}

Equivalent to fetch(Db, all_docs, []).

fetch all docs

all/2

all(Db::db(), Options::view_options()) -> {ok, Rows::[ejson_object()]} | {error, term()}

Equivalent to fetch(Db, all_docs, Options).

fetch all docs

count/1

count(Db::db()) -> integer() | {error, term()}

Equivalent to count(Db, all_docs, []).

count/2

count(Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}) -> integer() | {error, term()}

Equivalent to count(Db, ViewName, []).

count/3

count(Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}, Options::view_options()) -> integer() | {error, term()}

count number of doc in a view (or all docs)

fetch/1

fetch(Db::db()) -> {ok, Rows::[ejson_object()]} | {error, term()}

Equivalent to fetch(Db, all_docs, []).

fetch/2

fetch(Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}) -> {ok, Rows::[ejson_object()]} | {error, term()}

Equivalent to fetch(Db, ViewName, []).

fetch/3

fetch(Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}, Options::view_options()) -> {ok, Rows::[ejson_object()]} | {error, term()}

Collect view results

Db: a db record

ViewName: 'all_docs' to get all docs or {DesignName, ViewName}

Options :: view_options() [{key, binary()} | {start_docid, binary()}
     | {end_docid, binary()} | {start_key, binary()}
     | {end_key, binary()} | {limit, integer()}
     | {stale, stale()}
     | descending
     | {skip, integer()}
     | group | {group_level, integer()}
     | {inclusive_end, boolean()} | {reduce, boolean()} | reduce | include_docs | conflicts
     | {keys, list(binary())}

See couchbeam_view:stream/4 for more information about options.

Return: {ok, Rows} or {error, Rows, Error}

first/1

first(Db::db()) -> {ok, Row::ejson_object()} | {error, term()}

Equivalent to first(Db, all_docs, []).

first/2

first(Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}) -> {ok, Row::ejson_object()} | {error, term()}

Equivalent to first(Db, ViewName, []).

first/3

first(Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}, Options::view_options()) -> {ok, Rows::ejson_object()} | {error, term()}

get first result of a view

Db: a db record

ViewName: 'all_docs' to get all docs or {DesignName, ViewName}

Options :: view_options() [{key, binary()} | {start_docid, binary()}
     | {end_docid, binary()} | {start_key, binary()}
     | {end_key, binary()} | {limit, integer()}
     | {stale, stale()}
     | descending
     | {skip, integer()}
     | group | {group_level, integer()}
     | {inclusive_end, boolean()} | {reduce, boolean()} | reduce | include_docs | conflicts
     | {keys, list(binary())}

See couchbeam_view:stream/4 for more information about options.

Return: {ok, Row} or {error, Error}

fold/4

fold(Function::function(), Acc::list(), Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}) -> [term()] | {error, term()}

Equivalent to fold(Function, Acc, Db, ViewName, []).

fold/5

fold(Function::function(), Acc::list(), Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}, Options::view_options()) -> [term()] | {error, term()}

call Function(Row, AccIn) on succesive row, starting with AccIn == Acc. Function/2 must return a new list accumultator or the atom done to stop fetching results. Acc0 is returned if the list is empty. For example:

  couchbeam_view:fold(fun(Row, Acc) -> [Row|Acc] end, [], Db, 'all_docs').

foreach/3

foreach(Function::function(), Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}) -> [term()] | {error, term()}

Equivalent to foreach(Function, Db, ViewName, []).

foreach/4

foreach(Function::function(), Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}, Options::view_options()) -> [term()] | {error, term()}

call Function(Row) on succesive row. Example:

  couchbeam_view:foreach(fun(Row) -> io:format("got row ~p~n", [Row]) end, Db, 'all_docs').

parse_view_options/1

parse_view_options(Options::list()) -> view_query_args()

parse view options

stream/2

stream(Db::db(), Client::pid()) -> {ok, StartRef::term(), ViewPid::pid()} | {error, term()}

Equivalent to stream(Db, all_docs, Client, []).

stream/3

stream(Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}, Client::pid()) -> {ok, StartRef::term(), ViewPid::pid()} | {error, term()}

Equivalent to stream(Db, ViewName, Client, []).

stream/4

stream(Db::db(), ViewName::all_docs | {DesignName::string(), ViewName::string()}, Client::pid(), Options::view_options()) -> {ok, StartRef::term(), ViewPid::pid()} | {error, term()}

stream view results to a pid

Db: a db record

ViewName: 'all_docs' to get all docs or {DesignName, ViewName}

Client: pid where to send view events where events are:

{row, StartRef, done}
All view results have been fetched
{row, StartRef, Row :: ejson_object()}
A row in the view
{error, StartRef, Error}
Got an error, connection is closed when an error happend.

Options :: view_options() [{key, binary()} | {start_docid, binary()}
     | {end_docid, binary()} | {start_key, binary()}
     | {end_key, binary()} | {limit, integer()}
     | {stale, stale()}
     | descending
     | {skip, integer()}
     | group | {group_level, integer()}
     | {inclusive_end, boolean()} | {reduce, boolean()} | reduce | include_docs | conflicts
     | {keys, list(binary())}

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

view_loop/2

view_loop(UserFun, Params) -> any()


Generated by EDoc, Aug 31 2012, 10:02:31.