couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Smith <...@couch.io>
Subject Re: Auto-UUID generation in _update [PATCH]
Date Sat, 12 Jun 2010 15:43:03 GMT
Yes, and of course _update functions can receive arbitrary input: CSV, XML,
whatever.

I simply like the pattern where they mimic the JSON API but add extra
seasoning.

It's a pickle.

On Sat, Jun 12, 2010 at 22:18, Paul Bonser <misterpib@gmail.com> wrote:

> I just realized that there's nothing keeping the update handler from
> generating a new document no matter if an existing document was passed
> in or not. So perhaps the uuid should simply always be added to the
> req passed into update handlers, so they always have one on hand if
> they want to create a new document?
>
> It could be handy if you want to generate a new document based on an
> existing document or related to an existing document, but want to
> leave the existing document intact.
>
> On Sat, Jun 12, 2010 at 10:16 AM, Paul Bonser <misterpib@gmail.com> wrote:
> > How about instead of the update function passing back a doc with no
> > ID, if no docid is specified, then a uuid is generated and passed to
> > the update handler in the req? That way it can pass the auto-generated
> > ID back to the client as well.
> >
> > See the attached patch.
> >
> > At first I was going to just suggest passing a new uuid in the DocID
> > attribute to json_req_obj, but the problem with that would be the
> > inability to distinguish between a non-existing user-supplied ID and
> > an auto-generated ID, so I instead added it to a new "uuid" attribute
> > on the request parameter to the update function.
> >
> > On Sat, Jun 12, 2010 at 6:24 AM, Jason Smith <jhs@couch.io> wrote:
> >> I enjoy using _show and _update functions to mimic the HTTP doc API,
> >> adding conveniences such as auto-timestamping, etc.
> >>
> >> One thing _update cannot duplicate vs. the normal API is automatic UUID
> >> generation when _id is unspecified
> >>
> >> The only solution is to generate a UUID in the update function; but this
> >> sacrifices reference locality using the (default) sequential internal
> >> UUID algorithm.
> >>
> >> Is this just something we have to endure, or can couchdb be made to fill
> >> it in?  In principle, I feel like _update is a convenience around the
> >> doc API. Auto-ID should be possible.
> >>
> >> Attached is a patch as food for thought; however it has a bug: the query
> >> server already computed the response (with arbitrary content-type and
> >> response body). It seems too late for the couch server to go inserting
> >> fields in the doc. But of course, the doc is invalid in the first place
> >> if _id is undefined.
> >>
> >> --
> >> Jason Smith
> >> Couchio Hosting
> >>
> >
> >
> >
> > --
> > Paul Bonser
> > http://probablyprogramming.com
> >
>
>
>
> --
> Paul Bonser
> http://probablyprogramming.com
>



-- 
Jason Smith
Couchio Hosting

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message