couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michele Sciabarra <>
Subject A modest proposal for a Couch Erlang API
Date Sun, 14 Sep 2008 23:02:27 GMT
Damien stated that the Erlang API should be simply documenting some 
internal functions of CouchDB.

I tried this approch and documented it in my blog 

Anyway I observed that is a bit dispersive. This is because of course 
the the various features are implemented in different modules.
It is not simple nor elegant documenting  a bunch of various functions 
in those modules, and the expose details are too often low level.

So I realized a sort of simplified wrapper was needed. As I was 
suggested, I started to see the httpd api and definitely I had the idea 
that an API, erlang or not, shoud mimic the httpd api.

As a general rule, to get the api I used the HTTP verb (get, post, put ) 
, added a suffix that is the "_xxx" meta operation when available, 
otherwise adding an arbitrary but descriptive suffix.

This is the result of my efforts:

% List all database

% Generate a new unique id

% Generate Count new unique id

% Create a database
put_db(DbName) when is_binary(DbName)

% Delete a database.

% Informations on a database

% Compact the database

% All documents
get_all_docs(Start, Count)
get_all_docs(Start, Count, Desc)

% Get a document
get_doc(Db, Doc)
get_doc(Db,Doc,revs)  % with revisions
get_doc(Db,Doc,Rev)   % of the specified revision

% Get an attachment
get_attachment(Db, Doc, Attachment)

% Create a new named document
put_doc_named(Db, Doc, Term)

% Insert or Replace and attachment
put_attachment(Db, Doc, Attachment) % insert
put_attachment(Db, Doc, Attachment, Rev)  % replace the given revision
% Create an unnamed document

% Bulk insert/update
post_bulk_docs(DbName, Docs)

A good start for implementing this api is the couch_http.erl. Actually I 
started to code it, and I am willing to contribuite it.
 But I am here asking if my proposed API could be acceptable.

View raw message