Module couchdb_documents
The
couchdb_documents
module contains functionality listed under CouchDB API
Reference section 1.4.1.
Description
The couchdb_documents
module contains functionality listed under CouchDB API
Reference section 1.4.1.
Function Index
delete/2 | Deletes a list of documents if you want to make sure the doc it emptied on delete, use the option {empty_on_delete, true} or pass a doc with just _id and _rev members. |
delete/3 | Deletes a list of documents if you want to make sure the doc it emptied on delete, use the option {empty_on_delete, true} or pass a doc with just _id and _rev members. |
exists/2 | Determine if Document exists. |
get/2 | Get a document. |
get/3 | Get a document Params is a list of query arguments.See CouchDB API Reference 1.4.1. |
lookup_rev/2 | get the last revision of the document. |
lookup_rev/3 | |
save/2 | save a document. |
save/3 | save a *document A document is a Json object like this one:. |
save/4 | save a *document with all its attacjments A document is a Json object like this one:. |
Function Details
delete/2
delete(Db, Document) -> any()
Deletes a list of documents if you want to make sure the doc it emptied on delete, use the option {empty_on_delete, true} or pass a doc with just _id and _rev members.
delete/3
delete(Db::db(), Document::map() | list(), Options::list()) -> {ok, _Result} | {error, _Error}
Deletes a list of documents if you want to make sure the doc it emptied on delete, use the option {empty_on_delete, true} or pass a doc with just _id and _rev members.
exists/2
exists(Db::db(), DocId::binary()) -> boolean()
Determine if Document exists
test if doc with uuid exists in the given dbget/2
get(Database::db(), DocId::binary()) -> {ok, map()} | {error, term()}
Equivalent to get(Db, DocId, [])
.
Get a document
get/3
get(Database::db(), DocId::binary(), Params::list()) -> {ok, map()} | {error, term()}
Get a document Params is a list of query arguments.See CouchDB API Reference 1.4.1
Note: The attachment option is still here but should be considered not supported as use of thecouchdb_attachments
module is
favoured.
lookup_rev/2
lookup_rev(Db, DocId) -> any()
get the last revision of the document
lookup_rev/3
lookup_rev(Db, DocId, Params) -> any()
save/3
save(Db::db(), Doc, Options::list()) -> {ok, Doc1} | {error, Error}
save a *document A document is a Json object like this one:
{[ {<<"_id">>, <<"myid">>}, {<<"title">>, <<"test">>} ]}Options are arguments passed to the request. This function return a new document with last revision and a docid. If _id isn't specified in document it will be created. Id is created by extracting an uuid from the couchdb node.
save/4
save(Db::db(), Doc::doc(), Atts::mp_attachments(), Options::list()) -> {ok, doc()} | {error, term()}
save a *document with all its attacjments A document is a Json object like this one:
{[ {<<"_id">>, <<"myid">>}, {<<"title">>, <<"test">>} ]}
Options are arguments passed to the request. This function return a new document with last revision and a docid. If _id isn't specified in document it will be created. Id is created by extracting an uuid from the couchdb node.
If the attachments is not empty, the doc will be sent as multipart. Attachments are passed as a list of the following tuples:
- {Name :: binary(), Bin :: binary()}
- {Name :: binary(), Bin :: binary(), Encoding :: binary()}
- { Name :: binary(), Bin :: binary(), Type :: binary(), Encoding :: binary()}
- { Name :: binary(), {file, Path :: string()}}
- { Name :: binary(), {file, Path :: string()}, Encoding :: binary()}
- { Name :: binary(), Fun :: fun(), Length :: integer()}
- { Name :: binary(), Fun :: fun(), Length :: integer(), Encoding :: binary()}
- {Name :: binary(), Fun :: fun(), Length :: integer(), Type :: binary(), Encoding :: binary()}
- { Name :: binary(), {Fun :: fun(), Acc :: any()}, Length :: integer()}
- { Name :: binary(), {Fun :: fun(), Acc :: any()}, Length :: integer(), Encoding :: binary()}
- { Name :: binary(), {Fun :: fun(), Acc :: any()}, Length :: integer(), Type :: binary(), Encoding :: binary()}.
Type` is the content-type of the attachments (detected in other
case) and `Encoding` the encoding of the attachments:
`<<"identity">>
if normal or <<"gzip">>
if the attachments is
gzipped.
Made with EDoc-S