Quantcast
Channel: CodeSection,代码区,数据库(综合) - CodeSec
Viewing all articles
Browse latest Browse all 6262

Cloudant Change Trigger no Longer Supports “includeDoc”

$
0
0

In using Cloudant package for IBM Bluemix OpenWhisk, there has been an option to use a parameter (‘includeDoc’), which attaches a specified document to the change feed. This parameter will be no longer supported as of December 9th, 2016, 6:00am PST.

If you use this parameter, to replicate the behavior in your OpenWhisk deployment, follow the steps to migrate the trigger logic.

If you do not make the updates below, your change feed will no longer continue to work and your actions will not execute in response to the change

First, recreate the trigger with no includeDoc parameter:

$ wsk trigger delete myCloudantTrigger

$ wsk trigger create myCloudantTrigger feed /myNamespace/myCloudant/changes param dbname testdb

Now, follow the steps below to create an action sequence to get the document and call your existing action. After, you will update your rule to use the new action sequence.

### Using an action sequence and a change trigger to get a document from a Cloudant database

You can use an action sequence in a rule to fetch the document associated with a Cloudant change event. To do that, create an action that processes a document from Cloudant. It will expect a document as a parameter.

Here is a sample code of an action that handles a document:

function main(doc){

return { “isWalter:” : doc.name === “Walter White”};

}

$ wsk action create myAction myAction.js

Now, create an action sequence that get’s the document first, then calls the current `myAction` that expects a document as input, as follows:

$ wsk action create sequenceAction sequence /myNamespace/myCloudant/read,myAction

With the action sequence created, create a rule that associates your trigger with the new action `sequenceAction`:

$ wsk rule create myRule myCloudantTrigger sequenceAction

To work properly, your action sequence needs to know the database name from which to fetch the document.

So set a parameter for ‘dbname’ on the new trigger:

$ wsk trigger update myCloudantTrigger param dbname testdb


Viewing all articles
Browse latest Browse all 6262

Trending Articles