From 75e7eb9ddde4f76653cabc0e84a6ce1c6052c5a5 Mon Sep 17 00:00:00 2001 From: Alex Schenkman Date: Sun, 9 Feb 2014 22:54:08 +0100 Subject: [PATCH] Added an example update handler to the readme. --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 5704e3e2..c9dbc1e5 100644 --- a/README.md +++ b/README.md @@ -593,6 +593,21 @@ db.atomic("update", "inplace", "foobar", }); ``` +Note that the data is sent in the body of the request. +An example update handler follows: + +``` js +"updates": { + "in-place" : "function(doc, req) { + var body = JSON.parse(req.body); + var field = body.field; + var value = body.value; + var message = 'set '+field+' to '+value; + doc[field] = value; + return [doc, message]; + }" +``` + ### db.search(designname, searchname, [params], [callback]) calls a view of the specified design with optional query string additions `params`.