← Back to team overview

u1db-discuss team mailing list archive

Re: API Design

 

On Thu, 2011-11-10 at 22:13 -0500, Rodney Dawes wrote:

>   Document   create_doc (string content, string doc_id=None)
>   Document   get_doc    (string doc_id, bool check_for_conflicts=True)
>   Document[] get_docs   (string doc_id[], bool check_for_conflicts=True)
>   long       put_doc    (Document)
>   void       delete_doc (Document)
> 
> Here, Document would be a simple object containing attributes for the
> id, revision, and content. The mentioned calls would still be on the
> Database object. The constructor arguments for Document, would be the
> id, revision, and content.
> 
> This sort of API design would make it easier to keep consistency across
> the board for all related methods, and would translate much better to
> other languages, such as C, Vala, Java, etc… which are not dynamic, and
> must have complex types defined to hold this data.

I think you might be under a bit of a misapprehension here. The thing
that you pass to the Python functions as a "doc" is a JSON string. It's
not a Python dictionary or some other complex type. Our basic "document"
is a string containing a JSON serialisation of the document; it's not an
object. 

sil




Follow ups

References