couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Bonser <mister...@gmail.com>
Subject Re: Auto-UUID generation in _update [PATCH]
Date Sat, 12 Jun 2010 15:16:02 GMT
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

Mime
View raw message