couchdb_connector v0.5.0 Couchdb.Connector.Writer
The Writer module provides functions to create and update documents in the CouchDB database given by the database properties.
Examples
db_props = %{protocol: "http", hostname: "localhost",database: "couchdb_connector_test", port: 5984}
%{database: "couchdb_connector_test", hostname: "localhost", port: 5984, protocol: "http"}
Couchdb.Connector.Storage.storage_up(db_props)
{:ok, "{\"ok\":true}\n"}
Couchdb.Connector.Writer.create(db_props, "{\"key\": \"value\"}")
{:ok, "{\"ok\":true,\"id\":\"7dd00...\",\"rev\":\"1-59414e7...\"}\n",
[{"Server", "CouchDB/1.6.1 (Erlang OTP/18)"},
{"Location", "http://localhost:5984/couchdb_connector_test/7dd00..."},
{"ETag", "\"1-59414e7...\""}, {"Date", "Mon, 21 Dec 2015 16:13:23 GMT"},
{"Content-Type", "text/plain; charset=utf-8"},
{"Content-Length", "95"}, {"Cache-Control", "must-revalidate"}]}
Summary
Functions
Create a new document with given json and 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 with given json and 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
Update the given document. Note that an _id field must be contained in the document. A missing _id field will trigger a RuntimeError
Update the given document that is stored under the given id
Functions
create(Couchdb.Connector.Types.db_properties, String.t, String.t) :: {:ok, String.t, Couchdb.Connector.Types.headers} | {:error, String.t, Couchdb.Connector.Types.headers}
Create a new document with given json and 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(Couchdb.Connector.Types.db_properties, String.t) :: {:ok, String.t, Couchdb.Connector.Types.headers} | {:error, String.t, Couchdb.Connector.Types.headers}
Create a new document with given json and a CouchDB generated id. Fetching the uuid from CouchDB does of course incur a performance penalty as compared to providing one.
destroy(Couchdb.Connector.Types.db_properties, String.t, String.t) :: {:ok, String.t} | {:error, String.t}
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.
update(Couchdb.Connector.Types.db_properties, String.t) :: {:ok, String.t, Couchdb.Connector.Types.headers} | {:error, String.t, Couchdb.Connector.Types.headers}
Update the given document. Note that an _id field must be contained in the document. A missing _id field will trigger a RuntimeError.
update(Couchdb.Connector.Types.db_properties, String.t, String.t) :: {:ok, String.t, Couchdb.Connector.Types.headers} | {:error, String.t, Couchdb.Connector.Types.headers}
Update the given document that is stored under the given id.