Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Commit

Permalink
Added an example update handler to the readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
alesch committed Feb 9, 2014
1 parent c62f9fb commit 75e7eb9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -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`.
Expand Down

0 comments on commit 75e7eb9

Please sign in to comment.