Permalink
Browse files

Added an example update handler to the readme.

  • Loading branch information...
1 parent c62f9fb commit 75e7eb9ddde4f76653cabc0e84a6ce1c6052c5a5 @alesch alesch committed Feb 9, 2014
Showing with 15 additions and 0 deletions.
  1. +15 −0 README.md
View
@@ -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`.

0 comments on commit 75e7eb9

Please sign in to comment.