abstract datatype: doc_stream()
mp_attachments() = {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::function(), Length::integer()} | {Name::binary(), Fun::function(), Length::integer(), Encoding::binary()} | {Name::binary(), Fun::function(), Length::integer(), Type::binary(), Encoding::binary()} | {Name::binary(), {Fun::function(), Acc::any()}, Length::integer()} | {Name::binary(), {Fun::function(), Acc::any()}, Length::integer(), Encoding::binary()} | {Name::binary(), {Fun::function(), Acc::any()}, Length::integer(), Type::binary(), Encoding::binary()}
all_dbs/1 | get list of databases on a CouchDB node. |
all_dbs/2 | get list of databases on a CouchDB node with optional filter. |
compact/1 | Compaction compresses the database file by removing unused sections created during updates. |
compact/2 | Like compact/1 but this compacts the view index from the current version of the design document. |
copy_doc/2 | duplicate a document using the doc API. |
copy_doc/3 | copy a doc to a destination. |
create_db/2 | Create a database and a client for connectiong to it. |
create_db/3 | Create a database and a client for connectiong to it. |
create_db/4 | Create a database and a client for connectiong to it. |
db_exists/2 | test if db with dbname exists on the CouchDB node. |
db_info/1 | get database info. |
delete_attachment/3 | delete a document attachment. |
delete_attachment/4 | delete a document attachment. |
delete_config/3 | delete a key from the couchdb config. |
delete_config/4 | |
delete_db/1 | delete database. |
delete_db/2 | delete database. |
delete_doc/2 | delete a document. |
delete_doc/3 | delete a document 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_docs/2 | delete a list of documents. |
delete_docs/3 | delete 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. |
design_info/2 | |
doc_exists/2 | test if doc with uuid exists in the given db. |
end_doc_stream/1 | stop to receive the multipart response of the doc api and close the connection. |
ensure_full_commit/1 | commit all docs in memory. |
ensure_full_commit/2 | commit all docs in memory. |
fetch_attachment/3 | fetch a document attachment. |
fetch_attachment/4 | fetch a document attachment
Options are
|
get_config/1 | retrieve all the configuration from a couchdb node. |
get_config/2 | retrieve all the configuration from a section in the couchdb config. |
get_config/3 | retrieve a key value from the couchdb config. |
get_missing_revs/2 | get missing revisions. |
get_uuid/1 | Get one uuid from the server. |
get_uuids/2 | Get a list of uuids from the server. |
lookup_doc_rev/2 | get the last revision of the document. |
lookup_doc_rev/3 | |
open_db/2 | Create a client for connection to a database. |
open_db/3 | Create a client for connection to a database. |
open_doc/2 | open a document. |
open_doc/3 | open a document Params is a list of query argument. |
open_or_create_db/2 | Create a client for connecting to a database and create the database if needed. |
open_or_create_db/3 | Create a client for connecting to a database and create the database if needed. |
open_or_create_db/4 | Create a client for connecting to a database and create the database if needed. |
put_attachment/4 | put an attachment. |
put_attachment/5 | put an attachment. |
replicate/2 | Handle replication. |
replicate/3 | Handle replication. |
replicate/4 | handle Replication. |
save_doc/2 | save a document. |
save_doc/3 | save a *document A document is a Json object like this one:. |
save_doc/4 | save a *document with all its attacjments A document is a Json object like this one:. |
save_docs/2 | save a list of documents. |
save_docs/3 | save a list of documents. |
send_attachment/2 | send an attachment chunk Msg could be Data, eof to stop sending. |
server_connection/0 | Create a server for connectiong to a CouchDB node. |
server_connection/1 | |
server_connection/2 | Create a server for connectiong to a CouchDB node. |
server_connection/4 | Create a server for connectiong to a CouchDB node. |
server_info/1 | Get Information from the server. |
set_config/4 | set a key, value in the couchdb config. |
set_config/5 | |
stream_attachment/1 | fetch an attachment chunk. |
stream_doc/1 | stream the multipart response of the doc API. |
view_cleanup/1 |
all_dbs(Server::server()) -> {ok, iolist()}
get list of databases on a CouchDB node
all_dbs(Server::server(), Options::view_options()) -> {ok, iolist()}
get list of databases on a CouchDB node with optional filter
compact(Db::db()) -> ok | {error, term()}
Compaction compresses the database file by removing unused
sections created during updates.
See http://wiki.apache.org/couchdb/Compaction
for more informations
compact(Db::db(), ViewName::string()) -> ok | {error, term()}
Like compact/1 but this compacts the view index from the
current version of the design document.
See http://wiki.apache.org/couchdb/Compaction#View_compaction
for more informations
copy_doc(Db, Doc) -> any()
duplicate a document using the doc API
copy_doc(Db, Doc, Dest) -> any()
copy a doc to a destination. If the destination exist it will use the last revision, in other case a new doc is created with the the current doc revision.
create_db(Server, DbName) -> any()
Equivalent to create_db(Server, DbName, [], [])
.
Create a database and a client for connectiong to it.
create_db(Server, DbName, Options) -> any()
Equivalent to create_db(Server, DbName, Options, [])
.
Create a database and a client for connectiong to it.
create_db(Server::server(), DbName::string(), Options::optionList(), Params::list()) -> {ok, db() | {error, Error}}
Create a database and a client for connectiong to it.
Connections are made to:
http://Host:PortPrefix/DbName
If ssl is set https is used. See server_connections for options. Params is a list of optionnal query argument you want to pass to the db. Useful for bigcouch for example.
db_exists(Server::server(), DbName::string()) -> boolean()
test if db with dbname exists on the CouchDB node
db_info(Db::db()) -> {ok, iolist() | {error, Error}}
get database info
delete_attachment(Db, Doc, Name) -> any()
Equivalent to delete_attachment(Db, Doc, Name, [])
.
delete a document attachment
delete_attachment(Db, DocOrDocId, Name, Options) -> any()
delete a document attachment
delete_config(Server, Section, Key) -> any()
delete a key from the couchdb config
delete_config(Server, Section, Key, Persist) -> any()
delete_db(Db) -> any()
Equivalent to delete_db(Server, DbName)
.
delete database
delete_db(Server::server(), DbName) -> {ok, iolist() | {error, Error}}
delete database
delete_doc(Db, Doc) -> any()
Equivalent to delete_doc(Db, Doc, [])
.
delete a document
delete_doc(Db, Doc, Options) -> {ok, Result} | {error, Error}
delete a document 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_docs(Db, Docs) -> any()
Equivalent to delete_docs(Db, Docs, [])
.
delete a list of documents
delete_docs(Db::db(), Docs::list(), Options::list()) -> {ok, Result} | {error, Error}
delete 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.
design_info(Db, DesignName) -> any()
doc_exists(Db::db(), DocId::string()) -> boolean()
test if doc with uuid exists in the given db
end_doc_stream(X1::doc_stream()) -> ok
stop to receive the multipart response of the doc api and close the connection.
ensure_full_commit(Db) -> any()
Equivalent to ensure_full_commit(Db, [])
.
commit all docs in memory
ensure_full_commit(Db::db(), Options::list()) -> {ok, InstancestartTime::binary()} | {error, term()}
commit all docs in memory
fetch_attachment(Db, DocId, Name) -> any()
Equivalent to fetch_attachment(Db, DocId, Name, [])
.
fetch a document attachment
fetch_attachment(Db::db(), DocId::string(), Name::string(), Options0::list()) -> {ok, binary()} | {ok, atom()} | {error, term()}
fetch a document attachment Options are
-
stream
: to start streaming an attachment. the function return{ok, Ref}
where is a ref to the attachment -
Other options that can be sent using the REST API
get_config(Server) -> any()
retrieve all the configuration from a couchdb node.
get_config(Server, Section) -> any()
retrieve all the configuration from a section in the couchdb config.
get_config(Server, Section, Key) -> any()
retrieve a key value from the couchdb config
get_missing_revs(Db::#db{}, IdRevs::[{binary(), [binary()]}]) -> {ok, [{DocId::binary(), [MissingRev::binary()], [PossibleAncestor::binary()]}]} | {error, term()}
get missing revisions
Get one uuid from the server
Get a list of uuids from the server
lookup_doc_rev(Db, DocId) -> any()
get the last revision of the document
lookup_doc_rev(Db, DocId, Params) -> any()
open_db(Server, DbName) -> any()
Equivalent to open_db(Server, DbName, [])
.
Create a client for connection to a database
open_db(Server::server(), DbName::string(), Options::optionList()) -> {ok, db()}
Create a client for connection to a database
open_doc(Db, DocId) -> any()
Equivalent to open_doc(Db, DocId, [])
.
open a document
open_doc(Db::db(), DocId::string(), Params::list()) -> {ok, Doc} | {error, Error}
open a document Params is a list of query argument. Have a look in CouchDb API
open_or_create_db(Server, DbName) -> any()
Equivalent to open_or_create_db(Server, DbName, [], [])
.
Create a client for connecting to a database and create the database if needed.
open_or_create_db(Server, DbName, Options) -> any()
Equivalent to open_or_create_db(Server, DbName, Options, [])
.
Create a client for connecting to a database and create the database if needed.
open_or_create_db(Server::server(), DbName0::string(), Options::list(), Params::list()) -> {ok, db() | {error, Error}}
Create a client for connecting to a database and create the database if needed.
put_attachment(Db, DocId, Name, Body) -> any()
Equivalent to put_attachment(Db, DocId, Name, Body, [])
.
put an attachment
put_attachment(Db::db(), DocId::string(), Name::string(), Body::body(), Option::optionList()) -> {ok, iolist()}
optionList() = [option()]
option() = {rev, string()} | {content_type, string()} | {content_length, string()}
body() = [] | string() | binary() | fun_arity_0() | {fun_arity_1(), initial_state(), stream}
initial_state() = term()
put an attachment
replicate(Server::server(), RepObj::{list()}) -> {ok, Result} | {error, Error}
Handle replication. Pass an object containting all informations It allows to pass for example an authentication info
RepObj = {[
{<<"source">>, <<"sourcedb">>},
{<<"target">>, <<"targetdb">>},
{<<"create_target">>, true}
]}
replicate(Server, RepObj).
Handle replication.
replicate(Server, Source, Target, Options) -> any()
handle Replication. Allows to pass options with source and target. Options is a Json object. ex:
Options = [{<<"create_target">>, true}]}
couchbeam:replicate(S, "testdb", "testdb2", Options).
save_doc(Db, Doc) -> any()
Equivalent to save_doc(Db, Doc, [])
.
save a document
save_doc(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_doc(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.
save_docs(Db, Docs) -> any()
Equivalent to save_docs(Db, Docs, [])
.
save a list of documents
save_docs(Db::db(), Docs::list(), Options::list()) -> {ok, Result} | {error, Error}
save a list of documents
send_attachment(Ref, Msg) -> any()
send an attachment chunk Msg could be Data, eof to stop sending.
server_connection() -> any()
Equivalent to server_connection("127.0.0.1", 5984, "", [], false)
.
Create a server for connectiong to a CouchDB node
server_connection(URL) -> any()
server_connection(URL, Options) -> any()
Equivalent to server_connection(Host, Port, "", [])
.
Create a server for connectiong to a CouchDB node
server_connection(Host::string(), Port::integer(), Prefix::string(), Options::optionList()) -> Server::server()
optionList() = [option()]
option() = {is_ssl, boolean()} | {ssl_options, [SSLOpt]} | {pool_name, atom()} | {proxy_host, string()} | {proxy_port, integer()} | {proxy_user, string()} | {proxy_password, string()} | {basic_auth, {username(), password()}} | {cookie, string()} | {oauth, oauthOptions()}
username() = string()
password() = string()
SSLOpt = term()
oauthOptions() = [oauth()]
oauth() = {consumer_key, string()} | {token, string()} | {token_secret, string()} | {consumer_secret, string()} | {signature_method, string()}
Create a server for connectiong to a CouchDB node
Connections are made to:
http://Host:PortPrefix
If ssl is set https is used.
For a description of SSL Options, look in the ssl manpage.
server_info(Server::server()) -> {ok, iolist()}
Get Information from the server
set_config(Server, Section, Key, Value) -> any()
set a key, value in the couchdb config
set_config(Server, Section, Key, Value, Persist) -> any()
stream_attachment(Ref::atom()) -> {ok, binary()} | done | {error, term()}
fetch an attachment chunk.
Use this function when you pass the stream
option to the
couchbeam:fetch_attachment/4
function.
This function return the following response:
stream_doc(X1::doc_stream()) -> {doc, doc()} | {att, Name::binary(), doc_stream()} | {att_body, Name::binary(), Chunk::binary(), doc_stream()} | {att_eof, Name::binary(), doc_stream()} | eof | {error, term()}
stream the multipart response of the doc API. Use this function
when you get {ok, {multipart, State}}
from the function
couchbeam:open_doc/3
.
view_cleanup(Db) -> any()