couchdb_connector v0.4.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

Create a view with the given JavaScript code in the given design document. Admin credentials are required for this operation

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, using basic authentication. Will return a JSON document with an empty list of documents if no document with given key exists. Staleness is set to ‘update_after’ which will perform worse than ‘ok’ but deliver more up-to-date results

Find and return one document with given key in given view, using basic authentication. Will return a JSON document with an empty list of documents if no document with given key exists. Staleness is set to ‘ok’ which will perform better than ‘update_after’ but potentially deliver stale results

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’

Returns everything found for the given view in the given design document, using no authentication

Returns everything found for the given view in the given design document, using basic authentication

Functions

create_view(db_props, design, code)

Create a view with the given JavaScript code in the given design document.

create_view(db_props, admin_auth, design, code)

Create a view with the given JavaScript code in the given design document. Admin credentials are required for this operation.

document_by_key(db_props, view_key)

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(db_props, view_key, view_key)

Find and return one document with given key in given view, using basic authentication. Will return a JSON document with an empty list of documents if no document with given key exists. Staleness is set to ‘update_after’ which will perform worse than ‘ok’ but deliver more up-to-date results.

document_by_key(db_props, auth, view_key, atom)

Find and return one document with given key in given view, using basic authentication. Will return a JSON document with an empty list of documents if no document with given key exists. Staleness is set to ‘ok’ which will perform better than ‘update_after’ but potentially deliver stale results.

document_by_key(db_props, design, view, key, stale \\ :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 ‘update_after’.

fetch_all(db_props, design, view)

Returns everything found for the given view in the given design document, using no authentication.

fetch_all(db_props, auth, design, view)

Returns everything found for the given view in the given design document, using basic authentication.