Module couchdb_documents


Function Index

delete/2Deletes 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/3Deletes 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/2test if doc with uuid exists in the given db.
get/2open a document.
get/3open a document Params is a list of query argument.
lookup_rev/2get the last revision of the document.
lookup_rev/3
save/2save a document.
save/3save a *document A document is a Json object like this one:.
save/4save 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()

test if doc with uuid exists in the given db

get/2

get(Db, DocId) -> any()

Equivalent to open_doc(Db, DocId, []).

open a document

get/3

get(Db::db(), DocId::binary(), Params::list()) -> {ok, map()} | {error, term()}

open a document Params is a list of query argument. Have a look in CouchDb API

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/2

save(Db, Doc) -> any()

Equivalent to save(Db, Doc, []).

save a document

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()}.

where 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.


erlang logo

Made with EDoc-S