Dear Wiki user, You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The "Document_Update_Handlers" page has been changed by SimonDeBoer: http://wiki.apache.org/couchdb/Document_Update_Handlers?action=diff&rev1=22&rev2=23 Comment: Provide a hint on how to return the document that has been changed by this update handler. The handler function takes the most recent version of the document from the database and the http request environment as parameters. It returns a two-element array: the first element is the (updated or new) document, which is committed to the database. If the first element is null no document will be committed to the database. If you are updating an existing, it should already have an `_id` set, and if you are creating a new document, make sure to set its `_id` to something, either generated based on the input or the `req.uuid` provided. The second element is the response that will be sent back to the caller. + If you want the client to get the changed document (without an additional request) you can return it as the second element of the return array, but you need to turn it into a string first. + {{{#!highlight javascript + { + updates: { + "in-place": "function (doc, req) { + doc.field = req.form.field.new_value; + + return [doc, toJSON(doc)]; + }" + } + } + }}} + '''Note''' The document returned in this manner will have the "old" _rev, see the response section for how retrieve the new/current _rev. + == Request == The request parameter will look something like this for a update function designed to create a new document:
