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 16:13:10 GMT
On Sat, Jun 12, 2010 at 10:48 AM, Jason Smith <jhs@couch.io> wrote:
> 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.
>
>
> My feeling about that is, hey, nothing stops you from writing a bad update
> function. You could return invalid JSON already. So I kind of like your
> auto-id on the way in idea. However that still doesn't answer the problem
> that _update in general does not process JSON, it processes text.
>
> I wonder, for
>
>    function(doc, req) { ... }
>
> Why not have these three cases:
>
>  * Document update: doc is something, req.id == doc._id
>  * Document create, PUT to _update/some_id: doc is null, req.id is "some_id"
>  * Document create, POST to _update, doc is null, req.is is a random uuid
>
> The update function can decide whether or not to honor the "suggested" doc
> id but at least it is now capable of matching the JSON API.

Ah yes, making it a bit closer to the way that a regular PUT vs. POST
works. What if someone POSTs an ID as part of the _update request?
Return an error telling them that they can only include a doc ID as
part of a PUT?

>
> --
> Jason Smith
> Couchio Hosting
>



-- 
Paul Bonser
http://probablyprogramming.com

Mime
View raw message