Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new ecouch API #15

Open
GoogleCodeExporter opened this issue Nov 3, 2015 · 4 comments
Open

new ecouch API #15

GoogleCodeExporter opened this issue Nov 3, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

ecouch currently has the database parameters as the authorization
information encoded as application configuration. This means that ecouch
can only be used with a single couchdb instance.

In order to refactor this and allow for new kinds of uses, I am proposing
the following new API.  I believe that the old API can still be supported,
perhaps in ecouch_old module namespace?

The basic idea is to use parameterized modules to make API calls much easier.

I'm posting these here to see if there is any public comment or suggestions
before I start this work.

# New ecouch API

## Old API

### Base HTTP Operations

* url_get(Path, Options)
* url_post(Path, Data)
* url_put(Path, Data)
* url_delete(Path, Options)

### Database Operations

* db_create(DBName)
* db_delete(DBName)
* db_list()
* db_info(DBName)

### Document Operations

* doc_create(DBName, Doc)
* doc_create(DBName, DocName?, Doc)
* doc_update(DBName, DocName?, Doc)
* doc_delete(DBName, DocName?, Rev)
* doc_get(DBName, DocName?)
* doc_get(DBName, DocName?, Options)
* doc_get_all(DBName)
* doc_get_all(DBName, Options)

### View Operations

* view_create(ViewName?, Funs) - unimplemented
* view_update(ViewName?, Funs, Rev) - unimplemented
* view_delete(ViewName?, Rev) - unimplemented
* view_get(ViewName?) - unimplemented
* view_get(ViewName?, Rev) - unimplemented
* view_adhoc(DBName, Fun)
* view_adhoc(DBName, Fun, Options)
* view_access(DBName, DesignName?, ViewName?)
* view_access(DBName, DesignName?, ViewName?, Options)

### Bulk Operations

* doc_bulk_create(DBName, DocList?)
* doc_bulk_update(DBName, DocListRev?)

## New API

### Base HTTP Operations

This API will remain unchanged.

### Context Operations

Parameterized modules are used to create server and database specific
contexts to work with.

#### Server Contexts

Get a context with:

    ServerCtx? = ecouch:server(Host, Port[, Options])

Context functions:
* DBCtx = ServerCtx:database(DBName)
* ServerCtx:options()
* ServerCtx:list()
* ServerCtx:create(DBName)
* ServerCtx:delete(DBName)
* ServerCtx:info(DBName)
* ServerCtx:replicate(SourceUrl, TargetUrl?)
* ServerCtx:replicate_local(SrcName, TgtName?)
* ServerCtx:replicate_pull(SourceUrl, TgtName?)
* ServerCtx:replicate_push(SrcName, TargetUrl?)
* ServerCtx:stats()
* ServerCtx:stats(Group, Key)

#### Database Contexts

Get a database context with:

    DBCtx = ecouch:database(Host, Port, DBName[, Options])

or

    DBCtx = ServerCtx:database(DBName)

Database context functions:
* ServerCtx? = DBCtx:server()
* DBCtx:name()
* DBCtx:create(Doc)
* DBCtx:update(Doc)
* DBCtx:delete(DocName, Rev)
* DBCtx:get(DocName[, Options])
* DBCtx:get_attachment(DocName, AttachName?)
* DBCtx:create_attachment(DocName, AttachName?[, Rev]
* DBCtx:delete_attachment(DocName, AttachName?, Rev)
* DBCtx:list([Options])
* DBCtx:info()
* DBCtx:delete()
* DBCtx:create()
* DBCtx:compact()
* DBCtx:copy(DstName[, DestRev?])
* DBCtx:temp_view(Map, Reduce[, Options])
* DBCtx:query(DesignName, ViewName?[, Options])

##### Get Options

* full (boolean)
* revision (string)
* revinfo (boolean)

##### List Options

* descending (boolean)
* startkey (json)
* endkey (json)
* limit (integer)
* include_docs (boolean)
* keys (list of json)

##### Query Options

* key (json)
* startkey (json)
* startkey_docid (string)
* endkey (json)
* endkey_docid (string)
* limit (integer)
* stale (boolean)
* descending (boolean)
* skip (integer)
* group (boolean)
* group_level (integer)
* reduce (boolean)
* include_docs (boolean)
* keys (list of json) 



Original issue reported on code.google.com by [email protected] on 21 Apr 2009 at 4:34

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 21 Apr 2009 at 4:35

  • Added labels: Priority-High
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

Sound great! Have you seen hovercraft? http://github.com/jchris/hovercraft

Original comment by yoan.blanc on 22 Apr 2009 at 4:10

@GoogleCodeExporter
Copy link
Author

It looks great, but unfortunately seems to have the same limitation.  You can 
talk to
the couchdb applicationt that is running in the currently Erlang cluster, but 
not to
an arbitrary one, much less two arbitrary ones.

It would be nice if we could keep the same API though, so that it was easy to 
switch
out one for the other aside from the database setup bit.

Original comment by [email protected] on 23 Apr 2009 at 6:28

@GoogleCodeExporter
Copy link
Author

yet another erlang couchdb client:
http://github.com/benoitc/ecouchdbkit/tree

Original comment by yoan.blanc on 27 Jul 2009 at 7:34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant