Skip to content

Commit

Permalink
fix doc & ..
Browse files Browse the repository at this point in the history
fix #136 thanks!
  • Loading branch information
benoitc committed Oct 22, 2016
1 parent 699fad1 commit fc14a1f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 89 deletions.
65 changes: 5 additions & 60 deletions doc/couchbeam.md
Expand Up @@ -34,7 +34,7 @@ mp_attachments() = {Name::binary(), Bin::binary()} | {Name::binary(), Bin::binar

<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#all_dbs-1">all_dbs/1</a></td><td>get list of databases on a CouchDB node.</td></tr><tr><td valign="top"><a href="#all_dbs-2">all_dbs/2</a></td><td>get list of databases on a CouchDB node with optional filter.</td></tr><tr><td valign="top"><a href="#compact-1">compact/1</a></td><td>Compaction compresses the database file by removing unused
sections created during updates.</td></tr><tr><td valign="top"><a href="#compact-2">compact/2</a></td><td>Like compact/1 but this compacts the view index from the
current version of the design document.</td></tr><tr><td valign="top"><a href="#copy_doc-2">copy_doc/2</a></td><td>duplicate a document using the doc API.</td></tr><tr><td valign="top"><a href="#copy_doc-3">copy_doc/3</a></td><td>copy a doc to a destination.</td></tr><tr><td valign="top"><a href="#create_db-2">create_db/2</a></td><td>Create a database and a client for connectiong to it.</td></tr><tr><td valign="top"><a href="#create_db-3">create_db/3</a></td><td>Create a database and a client for connectiong to it.</td></tr><tr><td valign="top"><a href="#create_db-4">create_db/4</a></td><td>Create a database and a client for connectiong to it.</td></tr><tr><td valign="top"><a href="#db_exists-2">db_exists/2</a></td><td>test if db with dbname exists on the CouchDB node.</td></tr><tr><td valign="top"><a href="#db_info-1">db_info/1</a></td><td>get database info.</td></tr><tr><td valign="top"><a href="#delete_attachment-3">delete_attachment/3</a></td><td>delete a document attachment.</td></tr><tr><td valign="top"><a href="#delete_attachment-4">delete_attachment/4</a></td><td>delete a document attachment.</td></tr><tr><td valign="top"><a href="#delete_config-3">delete_config/3</a></td><td>delete a key from the couchdb config.</td></tr><tr><td valign="top"><a href="#delete_config-4">delete_config/4</a></td><td></td></tr><tr><td valign="top"><a href="#delete_db-1">delete_db/1</a></td><td>delete database.</td></tr><tr><td valign="top"><a href="#delete_db-2">delete_db/2</a></td><td>delete database.</td></tr><tr><td valign="top"><a href="#delete_doc-2">delete_doc/2</a></td><td>delete a document.</td></tr><tr><td valign="top"><a href="#delete_doc-3">delete_doc/3</a></td><td>delete a document
current version of the design document.</td></tr><tr><td valign="top"><a href="#copy_doc-2">copy_doc/2</a></td><td>duplicate a document using the doc API.</td></tr><tr><td valign="top"><a href="#copy_doc-3">copy_doc/3</a></td><td>copy a doc to a destination.</td></tr><tr><td valign="top"><a href="#create_db-2">create_db/2</a></td><td>Create a database and a client for connectiong to it.</td></tr><tr><td valign="top"><a href="#create_db-3">create_db/3</a></td><td>Create a database and a client for connectiong to it.</td></tr><tr><td valign="top"><a href="#create_db-4">create_db/4</a></td><td>Create a database and a client for connectiong to it.</td></tr><tr><td valign="top"><a href="#db_exists-2">db_exists/2</a></td><td>test if db with dbname exists on the CouchDB node.</td></tr><tr><td valign="top"><a href="#db_info-1">db_info/1</a></td><td>get database info.</td></tr><tr><td valign="top"><a href="#delete_attachment-3">delete_attachment/3</a></td><td>delete a document attachment.</td></tr><tr><td valign="top"><a href="#delete_attachment-4">delete_attachment/4</a></td><td>delete a document attachment.</td></tr><tr><td valign="top"><a href="#delete_db-1">delete_db/1</a></td><td>delete database.</td></tr><tr><td valign="top"><a href="#delete_db-2">delete_db/2</a></td><td>delete database.</td></tr><tr><td valign="top"><a href="#delete_doc-2">delete_doc/2</a></td><td>delete a document.</td></tr><tr><td valign="top"><a href="#delete_doc-3">delete_doc/3</a></td><td>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.</td></tr><tr><td valign="top"><a href="#delete_docs-2">delete_docs/2</a></td><td>delete a list of documents.</td></tr><tr><td valign="top"><a href="#delete_docs-3">delete_docs/3</a></td><td>delete a list of documents
Expand All @@ -47,15 +47,14 @@ Options are
<li><code>stream</code>: to start streaming an attachment. the function return
<code>{ok, Ref}</code> where is a ref to the attachment</li>
<li>Other options that can be sent using the REST API</li>
</ul>.</td></tr><tr><td valign="top"><a href="#get_config-1">get_config/1</a></td><td>retrieve all the configuration from a couchdb node.</td></tr><tr><td valign="top"><a href="#get_config-2">get_config/2</a></td><td>retrieve all the configuration from a section in the couchdb
config.</td></tr><tr><td valign="top"><a href="#get_config-3">get_config/3</a></td><td>retrieve a key value from the couchdb config.</td></tr><tr><td valign="top"><a href="#get_missing_revs-2">get_missing_revs/2</a></td><td>get missing revisions.</td></tr><tr><td valign="top"><a href="#get_uuid-1">get_uuid/1</a></td><td>Get one uuid from the server.</td></tr><tr><td valign="top"><a href="#get_uuids-2">get_uuids/2</a></td><td>Get a list of uuids from the server.</td></tr><tr><td valign="top"><a href="#lookup_doc_rev-2">lookup_doc_rev/2</a></td><td>get the last revision of the document.</td></tr><tr><td valign="top"><a href="#lookup_doc_rev-3">lookup_doc_rev/3</a></td><td></td></tr><tr><td valign="top"><a href="#open_db-2">open_db/2</a></td><td>Create a client for connection to a database.</td></tr><tr><td valign="top"><a href="#open_db-3">open_db/3</a></td><td>Create a client for connection to a database.</td></tr><tr><td valign="top"><a href="#open_doc-2">open_doc/2</a></td><td>open a document.</td></tr><tr><td valign="top"><a href="#open_doc-3">open_doc/3</a></td><td>open a document
</ul>.</td></tr><tr><td valign="top"><a href="#get_missing_revs-2">get_missing_revs/2</a></td><td>get missing revisions.</td></tr><tr><td valign="top"><a href="#get_uuid-1">get_uuid/1</a></td><td>Get one uuid from the server.</td></tr><tr><td valign="top"><a href="#get_uuids-2">get_uuids/2</a></td><td>Get a list of uuids from the server.</td></tr><tr><td valign="top"><a href="#lookup_doc_rev-2">lookup_doc_rev/2</a></td><td>get the last revision of the document.</td></tr><tr><td valign="top"><a href="#lookup_doc_rev-3">lookup_doc_rev/3</a></td><td></td></tr><tr><td valign="top"><a href="#open_db-2">open_db/2</a></td><td>Create a client for connection to a database.</td></tr><tr><td valign="top"><a href="#open_db-3">open_db/3</a></td><td>Create a client for connection to a database.</td></tr><tr><td valign="top"><a href="#open_doc-2">open_doc/2</a></td><td>open a document.</td></tr><tr><td valign="top"><a href="#open_doc-3">open_doc/3</a></td><td>open a document
Params is a list of query argument.</td></tr><tr><td valign="top"><a href="#open_or_create_db-2">open_or_create_db/2</a></td><td>Create a client for connecting to a database and create the
database if needed.</td></tr><tr><td valign="top"><a href="#open_or_create_db-3">open_or_create_db/3</a></td><td>Create a client for connecting to a database and create the
database if needed.</td></tr><tr><td valign="top"><a href="#open_or_create_db-4">open_or_create_db/4</a></td><td>Create a client for connecting to a database and create the
database if needed.</td></tr><tr><td valign="top"><a href="#put_attachment-4">put_attachment/4</a></td><td>put an attachment.</td></tr><tr><td valign="top"><a href="#put_attachment-5">put_attachment/5</a></td><td>put an attachment.</td></tr><tr><td valign="top"><a href="#replicate-2">replicate/2</a></td><td>Handle replication.</td></tr><tr><td valign="top"><a href="#replicate-3">replicate/3</a></td><td>Handle replication.</td></tr><tr><td valign="top"><a href="#replicate-4">replicate/4</a></td><td>handle Replication.</td></tr><tr><td valign="top"><a href="#save_doc-2">save_doc/2</a></td><td>save a document.</td></tr><tr><td valign="top"><a href="#save_doc-3">save_doc/3</a></td><td>save a *document
A document is a Json object like this one:.</td></tr><tr><td valign="top"><a href="#save_doc-4">save_doc/4</a></td><td>save a *document with all its attacjments
A document is a Json object like this one:.</td></tr><tr><td valign="top"><a href="#save_docs-2">save_docs/2</a></td><td>save a list of documents.</td></tr><tr><td valign="top"><a href="#save_docs-3">save_docs/3</a></td><td>save a list of documents.</td></tr><tr><td valign="top"><a href="#send_attachment-2">send_attachment/2</a></td><td>send an attachment chunk
Msg could be Data, eof to stop sending.</td></tr><tr><td valign="top"><a href="#server_connection-0">server_connection/0</a></td><td>Create a server for connectiong to a CouchDB node.</td></tr><tr><td valign="top"><a href="#server_connection-1">server_connection/1</a></td><td></td></tr><tr><td valign="top"><a href="#server_connection-2">server_connection/2</a></td><td>Create a server for connectiong to a CouchDB node.</td></tr><tr><td valign="top"><a href="#server_connection-4">server_connection/4</a></td><td>Create a server for connectiong to a CouchDB node.</td></tr><tr><td valign="top"><a href="#server_info-1">server_info/1</a></td><td>Get Information from the server.</td></tr><tr><td valign="top"><a href="#set_config-4">set_config/4</a></td><td>set a key, value in the couchdb config.</td></tr><tr><td valign="top"><a href="#set_config-5">set_config/5</a></td><td></td></tr><tr><td valign="top"><a href="#stream_attachment-1">stream_attachment/1</a></td><td>fetch an attachment chunk.</td></tr><tr><td valign="top"><a href="#stream_doc-1">stream_doc/1</a></td><td>stream the multipart response of the doc API.</td></tr><tr><td valign="top"><a href="#view_cleanup-1">view_cleanup/1</a></td><td></td></tr></table>
Msg could be Data, eof to stop sending.</td></tr><tr><td valign="top"><a href="#server_connection-0">server_connection/0</a></td><td>Create a server for connectiong to a CouchDB node.</td></tr><tr><td valign="top"><a href="#server_connection-1">server_connection/1</a></td><td></td></tr><tr><td valign="top"><a href="#server_connection-2">server_connection/2</a></td><td>Create a server for connectiong to a CouchDB node.</td></tr><tr><td valign="top"><a href="#server_connection-4">server_connection/4</a></td><td>Create a server for connectiong to a CouchDB node.</td></tr><tr><td valign="top"><a href="#server_info-1">server_info/1</a></td><td>Get Information from the server.</td></tr><tr><td valign="top"><a href="#stream_attachment-1">stream_attachment/1</a></td><td>fetch an attachment chunk.</td></tr><tr><td valign="top"><a href="#stream_doc-1">stream_doc/1</a></td><td>stream the multipart response of the doc API.</td></tr><tr><td valign="top"><a href="#view_cleanup-1">view_cleanup/1</a></td><td></td></tr></table>


<a name="functions"></a>
Expand Down Expand Up @@ -209,20 +208,6 @@ delete a document attachment

delete a document attachment

<a name="delete_config-3"></a>

### delete_config/3 ###

`delete_config(Server, Section, Key) -> any()`

delete a key from the couchdb config

<a name="delete_config-4"></a>

### delete_config/4 ###

`delete_config(Server, Section, Key, Persist) -> any()`

<a name="delete_db-1"></a>

### delete_db/1 ###
Expand Down Expand Up @@ -371,31 +356,6 @@ Options are



<a name="get_config-1"></a>

### get_config/1 ###

`get_config(Server) -> any()`

retrieve all the configuration from a couchdb node.

<a name="get_config-2"></a>

### get_config/2 ###

`get_config(Server, Section) -> any()`

retrieve all the configuration from a section in the couchdb
config.

<a name="get_config-3"></a>

### get_config/3 ###

`get_config(Server, Section, Key) -> any()`

retrieve a key value from the couchdb config

<a name="get_missing_revs-2"></a>

### get_missing_revs/2 ###
Expand Down Expand Up @@ -729,10 +689,9 @@ Create a server for connectiong to a CouchDB node
### server_connection/4 ###

<pre><code>
server_connection(Host::string(), Port::integer(), Prefix::string(), Options::<a href="#type-optionList">optionList()</a>) -&gt; Server::<a href="#type-server">server()</a>
server_connection(Host::string(), Port::non_neg_integer(), Prefix::string(), OptionsList::list()) -&gt; Server::<a href="#type-server">server()</a>
</code></pre>

<ul class="definitions"><li><code><a name="type-optionList">optionList()</a> = [<a href="#type-option">option()</a>]</code></li><li><code><a name="type-option">option()</a> = {is_ssl, boolean()} | {ssl_options, [SSLOpt]} | {pool_name, atom()} | {proxy_host, string()} | {proxy_port, integer()} | {proxy_user, string()} | {proxy_password, string()} | {basic_auth, {<a href="#type-username">username()</a>, <a href="#type-password">password()</a>}} | {cookie, string()} | {oauth, <a href="#type-oauthOptions">oauthOptions()</a>}</code></li><li><code><a name="type-username">username()</a> = string()</code></li><li><code><a name="type-password">password()</a> = string()</code></li><li><code>SSLOpt = term()</code></li><li><code><a name="type-oauthOptions">oauthOptions()</a> = [<a href="#type-oauth">oauth()</a>]</code></li><li><code><a name="type-oauth">oauth()</a> = {consumer_key, string()} | {token, string()} | {token_secret, string()} | {consumer_secret, string()} | {signature_method, string()}</code></li></ul>
<br />

Create a server for connectiong to a CouchDB node

Expand All @@ -757,20 +716,6 @@ server_info(Server::<a href="#type-server">server()</a>) -&gt; {ok, iolist()}

Get Information from the server

<a name="set_config-4"></a>

### set_config/4 ###

`set_config(Server, Section, Key, Value) -> any()`

set a key, value in the couchdb config

<a name="set_config-5"></a>

### set_config/5 ###

`set_config(Server, Section, Key, Value, Persist) -> any()`

<a name="stream_attachment-1"></a>

### stream_attachment/1 ###
Expand Down
2 changes: 1 addition & 1 deletion doc/couchbeam_view.md
Expand Up @@ -137,7 +137,7 @@ Options :: view_options() [{key, binary()} | {start_docid, binary()}
See [`couchbeam_view:stream/4`](couchbeam_view.md#stream-4) for more information about
options.

Return: {ok, Rows} or {error, Rows, Error}
Return: {ok, Rows} or {error, Error}

<a name="first-1"></a>

Expand Down
30 changes: 3 additions & 27 deletions src/couchbeam.erl
Expand Up @@ -88,10 +88,9 @@ server_connection(Host, Port) when is_integer(Port) ->
%%
%% For a description of SSL Options, look in the <a href="http://www.erlang.org/doc/apps/ssl/index.html">ssl</a> manpage.
%%
%% @spec server_connection(Host::string(), Port::integer(),
%% Prefix::string(), Options::optionList())
%% -> Server::server()
%% optionList() = [option()]
-spec server_connection(Host::string(), Port::non_neg_integer(), Prefix::string(), OptionsList::list()) ->
Server::server().
%% OptionsList() = [option()]
%% option() =
%% {is_ssl, boolean()} |
%% {ssl_options, [SSLOpt]} |
Expand Down Expand Up @@ -1020,29 +1019,6 @@ maybe_docid(Server, {DocProps}) ->
{DocProps}
end.

update_config(#server{url=ServerUrl, options=Opts}, Section, Key, Value,
Persist, Method) ->
PathParts = [<<"_config">>,
hackney_bstr:to_binary(Section),
hackney_bstr:to_binary(Key)],
Url = hackney_url:make_url(ServerUrl, PathParts, []),
Headers = [{<<"Content-Type">>, <<"application/json">>},
{<<"X-Couch-Persist">>, atom_to_binary(Persist, latin1)}],

Body = case Method of
delete -> <<>>;
put -> couchbeam_ejson:encode(Value)
end,

Resp = couchbeam_httpc:db_request(Method, Url, Headers, Body, Opts,
[200]),
case Resp of
{ok, _, _, Ref} ->
{ok, couchbeam_httpc:json_body(Ref)};
Error ->
Error
end.

-ifdef(TEST).

-include_lib("eunit/include/eunit.hrl").
Expand Down
2 changes: 1 addition & 1 deletion src/couchbeam_view.erl
Expand Up @@ -62,7 +62,7 @@ fetch(Db, ViewName) ->
%% | {keys, list(binary())}</pre>
%% <p>See {@link couchbeam_view:stream/4} for more information about
%% options.</p>
%% <p>Return: {ok, Rows} or {error, Rows, Error}</p>
%% <p>Return: {ok, Rows} or {error, Error}</p>
fetch(Db, ViewName, Options) ->
case stream(Db, ViewName, Options) of
{ok, Ref} ->
Expand Down

0 comments on commit fc14a1f

Please sign in to comment.