Ibm cloud 如何使用节点red node cf cloudant从插入/更新中获得结果 我在IBM BLUMIX IOT基金会提供的No.Red工作。它附带node red node cf cloudant包,可以轻松处理cloudant数据库操作。Cloudant out节点工作得很好。border me是什么Cloudant out节点没有输出可以告诉流插入/更新操作是否成功。现在我只能假设它总是成功的。有人有和我一样的问题吗?你的解决方案是什么?谢谢。
我认为其原理是可以将Ibm cloud 如何使用节点red node cf cloudant从插入/更新中获得结果 我在IBM BLUMIX IOT基金会提供的No.Red工作。它附带node red node cf cloudant包,可以轻松处理cloudant数据库操作。Cloudant out节点工作得很好。border me是什么Cloudant out节点没有输出可以告诉流插入/更新操作是否成功。现在我只能假设它总是成功的。有人有和我一样的问题吗?你的解决方案是什么?谢谢。,ibm-cloud,cloudant,node-red,Ibm Cloud,Cloudant,Node Red,我认为其原理是可以将Catch节点的概念添加到流中。请参阅标记为catch的节点的input类别。在阅读此节点的文档时,它指出,如果同一选项卡/页面/工作流上的任何节点引发错误,将触发此节点。我假设如果Cloudant out节点实现正确,那么如果它失败,它将抛出一些节点红色格式的错误,这将导致触发Catch节点,这样您就可以控制执行任何可能适用的错误处理、日志记录或其他补救工作 我猜想,可以在这里找到跟踪创建的节点红色Github问题,其中可以阅读更多关于该功能的信息: 我认为其原理是有一个可
Catch
节点的概念添加到流中。请参阅标记为catch
的节点的input
类别。在阅读此节点的文档时,它指出,如果同一选项卡/页面/工作流上的任何节点引发错误,将触发此节点。我假设如果Cloudant out节点实现正确,那么如果它失败,它将抛出一些节点红色格式的错误,这将导致触发Catch
节点,这样您就可以控制执行任何可能适用的错误处理、日志记录或其他补救工作
我猜想,可以在这里找到跟踪创建的节点红色Github问题,其中可以阅读更多关于该功能的信息:
我认为其原理是有一个可以添加到流中的
Catch
节点的概念。请参阅标记为catch
的节点的input
类别。在阅读此节点的文档时,它指出,如果同一选项卡/页面/工作流上的任何节点引发错误,将触发此节点。我假设如果Cloudant out节点实现正确,那么如果它失败,它将抛出一些节点红色格式的错误,这将导致触发Catch
节点,这样您就可以控制执行任何可能适用的错误处理、日志记录或其他补救工作
我猜想,可以在这里找到跟踪创建的节点红色Github问题,其中可以阅读更多关于该功能的信息:
我有一个答案,尽管它不是一个很有用的答案
[
{
"id": "a477543c.5b88a8",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 293,
"y": 147,
"wires": []
},
{
"id": "8c8b0763.7374f8",
"type": "cloudant out",
"z": "7ac871fa.85379",
"service": "your_service",
"cloudant": "",
"name": "Save Data",
"database": "your_db",
"payonly": true,
"operation": "insert",
"x": 292,
"y": 58,
"wires": []
},
{
"id": "66f48698.990b78",
"type": "template",
"z": "7ac871fa.85379",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "json",
"template": "{\"response\": \"success\"}",
"x": 669,
"y": 112,
"wires": [
[
"9fc752f6.6038b"
]
]
},
{
"id": "9a2f1021.65d0f",
"type": "catch",
"z": "7ac871fa.85379",
"name": "Catch error from Save Data",
"scope": [
"8c8b0763.7374f8"
],
"x": 130,
"y": 207,
"wires": [
[
"41c37106.be3c9",
"35676738.ca9898",
"9e4a94f4.61b568"
]
]
},
{
"id": "41c37106.be3c9",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "true",
"complete": "true",
"x": 316,
"y": 249,
"wires": []
},
{
"id": "35676738.ca9898",
"type": "change",
"z": "7ac871fa.85379",
"name": "",
"rules": [
{
"t": "set",
"p": "error",
"pt": "flow",
"to": "error",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 330,
"y": 207,
"wires": [
[
"6c19d8c0.93e628"
]
]
},
{
"id": "972775b7.68d888",
"type": "delay",
"z": "7ac871fa.85379",
"name": "",
"pauseType": "delay",
"timeout": "3",
"timeoutUnits": "seconds",
"rate": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 286,
"y": 106,
"wires": [
[
"dd0eb63d.22f148"
]
]
},
{
"id": "dd0eb63d.22f148",
"type": "switch",
"z": "7ac871fa.85379",
"name": "Check flow.error",
"property": "error",
"propertyType": "flow",
"rules": [
{
"t": "nnull"
},
{
"t": "else"
}
],
"checkall": "true",
"outputs": 2,
"x": 467,
"y": 106,
"wires": [
[
"54a9c22f.ab563c"
],
[
"66f48698.990b78"
]
]
},
{
"id": "a26776ff.5d9888",
"type": "template",
"z": "7ac871fa.85379",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "json",
"template": "{\"response\": {{{payload}}}}\n",
"x": 975,
"y": 55,
"wires": [
[
"9fc752f6.6038b"
]
]
},
{
"id": "54a9c22f.ab563c",
"type": "change",
"z": "7ac871fa.85379",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "error",
"tot": "flow"
},
{
"t": "delete",
"p": "error",
"pt": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 687,
"y": 55,
"wires": [
[
"837ec67c.7c8138"
]
]
},
{
"id": "6c19d8c0.93e628",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 505,
"y": 207,
"wires": []
},
{
"id": "433fc13d.bcc04",
"type": "inject",
"z": "7ac871fa.85379",
"name": "",
"topic": "",
"payload": "{\"_id\":\"0fc076a605741fdffa1580897e1c54a0\",\"message\":\"testing\"}",
"payloadType": "json",
"repeat": "",
"crontab": "",
"once": false,
"x": 120,
"y": 57,
"wires": [
[
"8c8b0763.7374f8",
"972775b7.68d888",
"a477543c.5b88a8"
]
]
},
{
"id": "9fc752f6.6038b",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 1119,
"y": 108,
"wires": []
},
{
"id": "9e4a94f4.61b568",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "false",
"complete": "error",
"x": 330,
"y": 297,
"wires": []
},
{
"id": "837ec67c.7c8138",
"type": "json",
"z": "7ac871fa.85379",
"name": "",
"x": 843,
"y": 55,
"wires": [
[
"a26776ff.5d9888"
]
]
}
]
检查此代码。我可以使用catch节点捕获cloudantout节点抛出的任何错误,并将其设置为流上下文对象。因此,原始路径可以在短暂延迟后检查上下文中是否存在错误对象。如果在上下文中未找到错误,则假定更新成功
然而,这不是一个有用的解决方案。当在同一个节点实例中收到多个请求时,将出现并发问题。错误对象中没有会话标识符。我无法将错误消息与导致错误的消息相关联。希望有人能想出一种改进此解决方案的方法。我有一个答案,尽管它不是一个非常有用的答案
[
{
"id": "a477543c.5b88a8",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 293,
"y": 147,
"wires": []
},
{
"id": "8c8b0763.7374f8",
"type": "cloudant out",
"z": "7ac871fa.85379",
"service": "your_service",
"cloudant": "",
"name": "Save Data",
"database": "your_db",
"payonly": true,
"operation": "insert",
"x": 292,
"y": 58,
"wires": []
},
{
"id": "66f48698.990b78",
"type": "template",
"z": "7ac871fa.85379",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "json",
"template": "{\"response\": \"success\"}",
"x": 669,
"y": 112,
"wires": [
[
"9fc752f6.6038b"
]
]
},
{
"id": "9a2f1021.65d0f",
"type": "catch",
"z": "7ac871fa.85379",
"name": "Catch error from Save Data",
"scope": [
"8c8b0763.7374f8"
],
"x": 130,
"y": 207,
"wires": [
[
"41c37106.be3c9",
"35676738.ca9898",
"9e4a94f4.61b568"
]
]
},
{
"id": "41c37106.be3c9",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "true",
"complete": "true",
"x": 316,
"y": 249,
"wires": []
},
{
"id": "35676738.ca9898",
"type": "change",
"z": "7ac871fa.85379",
"name": "",
"rules": [
{
"t": "set",
"p": "error",
"pt": "flow",
"to": "error",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 330,
"y": 207,
"wires": [
[
"6c19d8c0.93e628"
]
]
},
{
"id": "972775b7.68d888",
"type": "delay",
"z": "7ac871fa.85379",
"name": "",
"pauseType": "delay",
"timeout": "3",
"timeoutUnits": "seconds",
"rate": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 286,
"y": 106,
"wires": [
[
"dd0eb63d.22f148"
]
]
},
{
"id": "dd0eb63d.22f148",
"type": "switch",
"z": "7ac871fa.85379",
"name": "Check flow.error",
"property": "error",
"propertyType": "flow",
"rules": [
{
"t": "nnull"
},
{
"t": "else"
}
],
"checkall": "true",
"outputs": 2,
"x": 467,
"y": 106,
"wires": [
[
"54a9c22f.ab563c"
],
[
"66f48698.990b78"
]
]
},
{
"id": "a26776ff.5d9888",
"type": "template",
"z": "7ac871fa.85379",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "json",
"template": "{\"response\": {{{payload}}}}\n",
"x": 975,
"y": 55,
"wires": [
[
"9fc752f6.6038b"
]
]
},
{
"id": "54a9c22f.ab563c",
"type": "change",
"z": "7ac871fa.85379",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "error",
"tot": "flow"
},
{
"t": "delete",
"p": "error",
"pt": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 687,
"y": 55,
"wires": [
[
"837ec67c.7c8138"
]
]
},
{
"id": "6c19d8c0.93e628",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 505,
"y": 207,
"wires": []
},
{
"id": "433fc13d.bcc04",
"type": "inject",
"z": "7ac871fa.85379",
"name": "",
"topic": "",
"payload": "{\"_id\":\"0fc076a605741fdffa1580897e1c54a0\",\"message\":\"testing\"}",
"payloadType": "json",
"repeat": "",
"crontab": "",
"once": false,
"x": 120,
"y": 57,
"wires": [
[
"8c8b0763.7374f8",
"972775b7.68d888",
"a477543c.5b88a8"
]
]
},
{
"id": "9fc752f6.6038b",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 1119,
"y": 108,
"wires": []
},
{
"id": "9e4a94f4.61b568",
"type": "debug",
"z": "7ac871fa.85379",
"name": "",
"active": true,
"console": "false",
"complete": "error",
"x": 330,
"y": 297,
"wires": []
},
{
"id": "837ec67c.7c8138",
"type": "json",
"z": "7ac871fa.85379",
"name": "",
"x": 843,
"y": 55,
"wires": [
[
"a26776ff.5d9888"
]
]
}
]
检查此代码。我可以使用catch节点捕获cloudantout节点抛出的任何错误,并将其设置为流上下文对象。因此,原始路径可以在短暂延迟后检查上下文中是否存在错误对象。如果在上下文中未找到错误,则假定更新成功
然而,这不是一个有用的解决方案。当在同一个节点实例中收到多个请求时,将出现并发问题。错误对象中没有会话标识符。我无法将错误消息与导致错误的消息相关联。希望有人能找到一种改进此解决方案的方法。cloudant节点的日期早于Catch节点,因此可能不会以这种方式记录错误以触发Catch节点。我知道Catch节点可能会完成这项工作,但有相当多的限制,因为很多信息没有传递给Catch节点。如果需要向用户返回正确的错误消息,很可能需要访问传递到Cloudant节点的整个消息。我开始认为我可以将捕获节点的错误保存在上下文对象(如flow或global)中。然后,原始路径将通过检查上下文中是否存在错误来知道更新是否成功。你认为这会奏效吗?@AlexHui-你提出了一个有趣的想法。就我个人而言,我认为你的要求行不通。原因是(这是一个猜测),导致Catch中唤醒的错误很可能意味着原始流的终止和Catch节点的“转到”。因此,尽管我们可以在Catch节点中设置一些全局上下文,但可能没有“其他路径”来感知它。我开始认为节点红色可能不是你需要的。。。可能需要考虑一个手写的JavaScript应用程序。Kolban,你可能是对的。我将建立一个流程来验证我的想法。我认为它可能会起作用的原因是,您总是可以从任何节点的输出分支出流。因此,即使Cloudant out确实停止了该路径上的执行流,另一个分支也可能一直运行到最后。让我们看看我会发现什么。cloudant节点在Catch节点之前,所以可能不会以触发Catch节点的方式记录错误。我知道Catch节点可能会做这项工作,但有很多限制,因为很多信息没有传递给Catch节点。如果需要向用户返回正确的错误消息,很可能需要访问传递到Cloudant节点的整个消息。我开始认为我可以将捕获节点的错误保存在上下文对象(如flow或global)中。然后,原始路径将通过检查上下文中是否存在错误来知道更新是否成功。你认为这会奏效吗?@AlexHui-你提出了一个有趣的想法。就我个人而言,我认为你的要求行不通。原因是(这是一个猜测)一个错误导致捕获中的唤醒很可能意味着错误