ICouch v0.2.1 ICouch.View View Source
Module to handle views in CouchDB.
View structs should not be created or manipulated directly, please use
ICouch.open_view/3
or ICouch.open_view!/3
.
The view struct implements the enumerable protocol for easy handling with
Elixir’s Enum
module.
A view can be in a “fetched” state or in an “unfetched” state which can be
tested with the fetched?/1
function and changed with the fetch/1
,
fetch!/1
and unfetch/1
function.
Link to this section Summary
Functions
Internal function to build a db endpoint
Deletes an option in view
Fetches all rows of view
, turning it into a “fetched view”
Same as fetch/1
but returns the fetched view directly on success or raises
an error on failure
Tests whether view
is in “fetched” state or not
Returns the value of an option in view
or nil
if it was not set
Adds or updates a single option in view
Replaces view
’s options with the given ones
Resets view
back to the “unfetched” state
Link to this section Types
t() :: %ICouch.View{db: ICouch.DB.t, ddoc: String.t | nil, name: String.t, params: map, rows: [map] | nil}
view_option_key :: :conflicts | :descending | :endkey | :endkey_docid | :group | :group_level | :include_docs | :attachments | :att_encoding_info | :inclusive_end | :key | :keys | :limit | :reduce | :skip | :stale | :startkey | :startkey_docid | :update_seq
view_option_value :: boolean | String.t | integer | [String.t] | :ok | :update_after
Link to this section Functions
Internal function to build a db endpoint.
delete_option(view :: t, key :: view_option_key) :: t
Deletes an option in view
.
This will also set the view back to the “unfetched” state.
Returns view
unchanged if the option was not set (and it already was
“unfetched”).
Fetches all rows of view
, turning it into a “fetched view”.
Same as fetch/1
but returns the fetched view directly on success or raises
an error on failure.
Tests whether view
is in “fetched” state or not.
get_option(view :: t, key :: view_option_key) :: view_option_value | nil
Returns the value of an option in view
or nil
if it was not set.
put_option(view :: t, key :: view_option_key, value :: view_option_value) :: t
Adds or updates a single option in view
.
This will also set the view back to the “unfetched” state.
set_options(view :: t, options :: [ICouch.open_view_option]) :: t
Replaces view
’s options with the given ones.
This will also set the view back to the “unfetched” state.
Resets view
back to the “unfetched” state.