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.

-- 
Jason Smith
Couchio Hosting

Reply via email to