couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zachary Zolton <zachary.zol...@gmail.com>
Subject Re: Document Updates handler using POST instead of PUT
Date Mon, 13 Dec 2010 16:22:09 GMT
When POSTing to an update handler you don't specify the ID in the URL.
Inside your function, you can either form the ID from query
parameters, or use the UUID that CouchDB provides.
—Zach

On Sat, Dec 11, 2010 at 12:13 PM, Josh803316 <josh803316@gmail.com> wrote:
> I'm following the wiki guide for document updates here:
> http://wiki.apache.org/couchdb/Document_Update_Handlers
>
> I created an update handler _design doc called "active_test", which will
> update the active_test value in my document and looks like this for PUT:
>
> "updates" : {
>            "active_test" : "function(doc, req) {
>                             var field         = req.query.field;
>                             var value       = req.query.value;
>                             var message = { "active_test": value };
>                             doc[field]      = value;
>                             return[doc,message];
>            }"
> }
>
> If I were to use a PUT request the url would look something like:
> <database>/_design/<design_doc>/_update/active_test/<doc_id> +
> '?field=active_test&value=' + value
>
> My question is what if I would like to use a POST instead.  (I know PUT is
> recommended but just for my own edification)
>
> I see from the wiki that a POST request should look like this:
> POST request against the handler function without a document id:
> /<database>/_design/<design_doc>/_update/active_test
>
> How is the docid sent for a POST?
>
> This information should probably be added to the wiki :)
>

Mime
View raw message