couchdb_connector v0.4.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
This function has been deprecated in version 0.3.0 and will be removed in a future release
Create a new document with given json and given id, using no authentication. 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 given id, using the provided basic authentication parameters. 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, using no authentication. Fetching the uuid from CouchDB does of course incur a performance penalty as compared to providing one
Create a new document with given json and a CouchDB generated id, using basic authentication. 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, using no authentication. An error will be returned in case the document does not exist or the revision is wrong
Delete the document with the given id in the given revision, using basic authentication. An error will be returned in case the document does not exist or the revision is wrong
Update the given document, using no authentication. 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, using no authentication
Update the given document that is stored under the given id, using basic authentication
Functions
create(Couchdb.Connector.Types.db_properties, String.t) :: {:ok, String.t, Couchdb.Connector.Types.headers} | {:error, String.t, Couchdb.Connector.Types.headers}
This function has been deprecated in version 0.3.0 and will be removed in a future release.
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, using no authentication. 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(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.basic_auth, 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, using the provided basic authentication parameters. 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, using no authentication. Fetching the uuid from CouchDB does of course incur a performance penalty as compared to providing one.
create_generate(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.basic_auth, 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, using basic authentication. 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, using no authentication. An error will be returned in case the document does not exist or the revision is wrong.
destroy(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.basic_auth, String.t, String.t) :: {:ok, String.t} | {:error, String.t}
Delete the document with the given id in the given revision, using basic authentication. 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, using no authentication. 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, Couchdb.Connector.Types.basic_auth, String.t) :: {:ok, String.t, Couchdb.Connector.Types.headers} | {:error, String.t, Couchdb.Connector.Types.headers}
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, using no authentication.
update(Couchdb.Connector.Types.db_properties, Couchdb.Connector.Types.basic_auth, 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, using basic authentication.