You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by gi...@git.apache.org on 2017/05/31 18:45:27 UTC

[GitHub] csantanapr commented on a change in pull request #101: update docs to include filter and query_params

csantanapr commented on a change in pull request #101: update docs to include filter and query_params
URL: https://github.com/apache/incubator-openwhisk-package-cloudant/pull/101#discussion_r119441072
 
 

 ##########
 File path: README.md
 ##########
 @@ -96,16 +96,55 @@ If you're not using OpenWhisk in Bluemix or if you want to set up your Cloudant
 
 ## Listening for changes to a Cloudant database
 
+### Filter database change events
+
+You can defined a filter function, to avoid having unnecessary change events firing your trigger.
+
+To create a new filter function you can use an action.
+
+Create a json document file `design_doc.json` with the following filter function
+```json
+{
+  "doc": {
+    "_id": "_design/mailbox",
+    "filters": {
+      "by_status": "function(doc, req){if (doc.status != req.query.status){return false;} return true;}"
+    }
+  }
+}
+```
+
+Create a new design document on the database with the filter function
+
+```
+wsk action invoke /_/myCloudant/write -p dbname testdb -p overwrite true -P design_doc.json -r
+```
+```json
+{
+    "id": "_design/mailbox",
+    "ok": true,
+    "rev": "1-5c361ed5141bc7856d4d7c24e4daddfd"
 
 Review comment:
   Oh this is just the output, not the input doc. the input doc is in design_doc.json.
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services