couchdb_connector v0.5.0 Couchdb.Connector.View
The View module provides functions for basic CouchDB view handling.
Examples
db_props = %{protocol: "http", hostname: "localhost",database: "couchdb_connector_test", port: 5984}
%{database: "couchdb_connector_test", hostname: "localhost", port: 5984, protocol: "http"}
view_code = File.read!("my_view.json")
Couchdb.Connector.View.create_view db_props, "my_design", view_code
Couchdb.Connector.View.document_by_key(db_props, "design_name", "view_name", "key")
{:ok, "{\"total_rows\":3,\"offset\":1,\"rows\":[\r\n{\"id\":\"5c09dbf93fd...\", ...}
Summary
Functions
Create a view with the given JavaScript code in the given design document. Please note that Admin credentials are required for this operation in case your database uses authentication
Find and return one document with given key in given view, using the given staleness setting. Will return a JSON document with an empty list of documents if no document with given key exists
Find and return one document with given key in given view. Will return a JSON document with an empty list of documents if no document with given key exists. Staleness is set to ‘update_after’
Find and return one document with given key in given view. Will return a JSON document with an empty list of documents if no document with given key exists. Staleness is set to ‘ok’
Returns everything found for the given view in the given design document
Functions
create_view(Couchdb.Connector.Types.db_properties, String.t, String.t) :: {:ok, String.t} | {:error, String.t}
Create a view with the given JavaScript code in the given design document. Please note that Admin credentials are required for this operation in case your database uses authentication.
do_document_by_key(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.view_key, :ok | :update_after) :: {:ok, String.t} | {:error, String.t}
Find and return one document with given key in given view, using the given staleness setting. Will return a JSON document with an empty list of documents if no document with given key exists.
document_by_key(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.view_key) :: {:ok, String.t} | {:error, String.t}
Find and return one document with given key in given view. Will return a JSON document with an empty list of documents if no document with given key exists. Staleness is set to ‘update_after’.
document_by_key(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.view_key, :update_after) :: {:ok, String.t} | {:error, String.t}
document_by_key(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.view_key, :ok) :: {:ok, String.t} | {:error, String.t}
Find and return one document with given key in given view. Will return a JSON document with an empty list of documents if no document with given key exists. Staleness is set to ‘ok’.
fetch_all(Couchdb.Connector.Types.db_properties, String.t, String.t) :: {:ok, String.t} | {:error, String.t}
Returns everything found for the given view in the given design document.