couchdb_connector v0.5.0 Couchdb.Connector

Your primary interface for writing to and reading from CouchDB. The exchange format here are Maps. If you want to go more low level and deal with JSON strings instead, please consider using Couchdb.Connector.Reader or Couchdb.Connector.Writer.

Summary

Functions

Create a new document from given map with given id. Clients must make sure that the id has not been used for an existing document in CouchDB. Either provide a UUID or consider using create_generate in case uniqueness cannot be guaranteed

Create a new document from given map with a CouchDB generated id. Fetching the uuid from CouchDB does of course incur a performance penalty as compared to providing one

Delete the document with the given id in the given revision. An error will be returned in case the document does not exist or the revision is wrong

Find and return one document with given key in given view. Will return a a Map 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 Map 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

Fetch a single uuid from CouchDB for use in a a subsequent create operation. Clients can retrieve the returned List of UUIDs by getting the value for key “uuids”. The List contains only one element (UUID)

Retrieve the document given by database properties and id, returning it as a Map

Update the given document, provided it contains an id field. Raise an error if it does not

Functions

create(db_props, doc_map, id)
create(Couchdb.Connector.Types.db_properties, map, String.t) ::
  {:ok, map} |
  {:error, map}

Create a new document from given map with given id. Clients must make sure that the id has not been used for an existing document in CouchDB. Either provide a UUID or consider using create_generate in case uniqueness cannot be guaranteed.

create_generate(db_props, doc_map)
create_generate(Couchdb.Connector.Types.db_properties, map) ::
  {:ok, map} |
  {:error, map}

Create a new document from given map with a CouchDB generated id. Fetching the uuid from CouchDB does of course incur a performance penalty as compared to providing one.

destroy(db_props, id, rev)
destroy(Couchdb.Connector.Types.db_properties, String.t, String.t) ::
  {:ok, map} |
  {:error, map}

Delete the document with the given id in the given revision. An error will be returned in case the document does not exist or the revision is wrong.

document_by_key(db_props, view_key)
document_by_key(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.view_key) ::
  {:ok, map} |
  {:error, map}

Find and return one document with given key in given view. Will return a a Map 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, atom)
document_by_key(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.view_key, :update_after) ::
  {:ok, map} |
  {:error, map}
document_by_key(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.view_key, :ok) ::
  {:ok, map} |
  {:error, map}

Find and return one document with given key in given view. Will return a Map with an empty list of documents if no document with given key exists. Staleness is set to ‘ok’.

fetch_all(db_props, design, view)
fetch_all(Couchdb.Connector.Types.db_properties, String.t, String.t) ::
  {:ok, map} |
  {:error, map}

Returns everything found for the given view in the given design document.

fetch_uuid(db_props)
fetch_uuid(Couchdb.Connector.Types.db_properties) ::
  {:ok, map} |
  {:error, String.t}

Fetch a single uuid from CouchDB for use in a a subsequent create operation. Clients can retrieve the returned List of UUIDs by getting the value for key “uuids”. The List contains only one element (UUID).

get(db_props, id)
get(Couchdb.Connector.Types.db_properties, String.t) ::
  {:ok, map} |
  {:error, map}

Retrieve the document given by database properties and id, returning it as a Map.

update(db_props, doc_map)
update(Couchdb.Connector.Types.db_properties, map) ::
  {:ok, map} |
  {:error, map}

Update the given document, provided it contains an id field. Raise an error if it does not.