On Sat, Jun 12, 2010 at 10:48 AM, Jason Smith <[email protected]> wrote:
> On Sat, Jun 12, 2010 at 22:18, Paul Bonser <[email protected]> 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

Reply via email to