简体   繁体   English

在功能节点中查询红色

[英]query in a function node-red

By executing a Query in a functional node of Node-Red, how can I refer the rusult of the Query inside the same node? 通过在Node-Red的功能节点中执行查询,如何在同一节点内引用查询的结果? We are attaching our node. 我们正在附加节点。 Or objectives is to create an automatic library, with this problem, we can not insert more than one equal book, with different ID. 或目标是创建一个自动库,因此,我们不能插入多个ID相同的同等书籍。

OUR NODE 我们的节点

[{"id":"893d2899.cc8238","type":"function","z":"16cd4688.876b29","name":"CICLO FOR MAGAZZINO","func":"var prova = null;\\nvar length = msg.payload.length;\\nfor(var i=0; i< length; i++){\\n var libroInAnalisi = msg.payload[i].idlibro;\\n var magazzino = msg.magazzino;\\n msg.topic = \\"SELECT idlibro FROM magazzino WHERE idmagazzino = \\" + msg.magazzino + \\" AND idlibro = \\" + msg.payload[i].idlibro;\\n prova = msg.paylod; /*we can not processed this msg.payload in our for cycle again. This result is not processed from the for but is our enter value; we need that this value will be the result of our query */\\n if (prova.length > 0 ) {\\n [{“ id”:“ 893d2899.cc8238”,“ type”:“ function”,“ z”:“ 16cd4688.876b29”,“ name”:“ CICLO FOR MAGAZZINO”,“ func”:“ var prova = null; \\ nvar length = msg.payload.length; \\ nfor(var i = 0; i <length; i ++){\\ n var libroInAnalisi = msg.payload [i] .idlibro; \\ n var magazzino = msg.magazzino; \\ n msg.topic = \\“从magazzino中选择idlibro,其中idmagazzino = \\” + msg.magazzino + \\“ AND idlibro = \\” + msg.payload [i] .idlibro; \\ n prova = msg.paylod; / *我们不能再次在for循环中处理了此msg.payload。此结果不是从for中处理的,而是我们的输入值;我们需要该值是查询* / \\ n的结果,如果(prova.length> 0){ \\ n
i = length;\\n return msg;\\n }\\n}\\nreturn msg;\\n i =长度; \\ n返回味精; \\ n} \\ n} \\ n返回味精; \\ n
\\n\\n","outputs":1,"noerr":0,"x":1960.3333740234375,"y":3691.333251953125,"wires":[[]]}] \\ n \\ n“,”输出“:1,” noerr“:0,” x“:1960.3333740234375,” y“:3691.333251953125,” wires“:[[]]}]

OUR NODE [{"id":"6c2611b5.7557c","type":"mqtt in","z":"16cd4688.876b29","name":"","topic":"InvioSedeTitolo","qos":"2","broker":"ef4521ef.a299c8","x":208.5001220703125,"y":3506.1668090820312,"wires":[["1a471c90.0a42db","2c52854d.e1abea"]]},{"id":"2c52854d.e1abea","type":"json","z":"16cd4688.876b29","name":"","property":"payload","action":"","pretty":false,"x":397.2620544433594,"y":3505.4763793945312,"wires":[["af4c5cbd.736df8"]]},{"id":"af4c5cbd.736df8","type":"change","z":"16cd4688.876b29","name":"","rules":[{"t":"set","p":"magazzino","pt":"msg","to":"payload.0","tot":"msg"},{"t":"set","p":"titolo","pt":"msg","to":"payload.1","tot":"msg"},{"t":"set","p":"autore","pt":"msg","to":"payload.2","tot":"msg"},{"t":"set","p":"chatId","pt":"msg","to":"payload.3","tot":"msg"},{"t":"set","p":"data","pt":"msg","to":"payload.4","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":606.5001220703125,"y":3504.1668090820312,"wires":[["2e07cb45.b7ccdc","9e50c718.365d58"]]},{"id":"9e 我们的节点[{“ id”:“ 6c2611b5.7557c”,“ type”:“ mqtt in”,“ z”:“ 16cd4688.876b29”,“ name”:“”,“ topic”:“ InvioSedeTitolo”,“ qos “:” 2“,”经纪人“:” ef4521ef.a299c8“,” x“:208.5001220703125,” y“:3506.1668090820312,”电线“:[[”“ 1a471c90.0a42db”,“ 2c52854d.e1abea”]]}},{ “ id”:“ 2c52854d.e1abea”,“ type”:“ json”,“ z”:“ 16cd4688.876b29”,“ name”:“”,“ property”:“ payload”,“ action”:“”, “ pretty”:false,“ x”:397.2620544433594,“ y”:3505.4763793945312,“ wires”:[[“” af4c5cbd.736df8“]]}},{” id“:” af4c5cbd.736df8“,” type“:” change “,” z“:” 16cd4688.876b29“,”名称“:”“,”规则“:[{” t“:” set“,” p“:” magazzino“,” pt“:” msg“,” to“:” payload.0“,” tot“:” msg“},{” t“:” set“,” p“:” titolo“,” pt“:” msg“,” to“:”有效载荷。 1“,” tot“:” msg“},{” t“:” set“,” p“:” autore“,” pt“:” msg“,” to“:” payload.2“,” tot“ :“ msg”},{“ t”:“ set”,“ p”:“ chatId”,“ pt”:“ msg”,“ to”:“ payload.3”,“ tot”:“ msg”}, {“ t”:“ set”,“ p”:“ data”,“ pt”:“ msg”,“ to”:“ payload.4”,“ tot”:“ msg”}],“ action”:“ “,” property“:”“,” from“:”“,” to“:”“,” reg“:false,” x“:606.5001220703125,” y“:3504.1668090820312,” wires“:[[” 2e07cb45。 b7ccdc“,” 9e50c718.365d58“]]},{” id“:” 9e 50c718.365d58","type":"change","z":"16cd4688.876b29","name":"SELECTidLibro","rules":[{"t":"set","p":"topic","pt":"msg","to":"SELECT idlibro FROM Libri WHERE titolo = ? 50c718.365d58“,” type“:” change“,” z“:” 16cd4688.876b29“,” name“:” SELECTidLibro“,” rules“:[{” t“:” set“,” p“:” topic“,” pt“:” msg“,” to“:” SELECT idlibro FROM Libri WHERE titolo =吗? AND autore = ? AND autore =? ","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"[\\tmsg.titolo,\\tmsg.autore\\t\\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":839.6668090820312,"y":3505.1670532226562,"wires":[["95314a01.d2eb58","ff75b9d0.a297c"]]},{"id":"95314a01.d2eb58","type":"mysql","z":"16cd4688.876b29","mydb":"ac96c738.c838b","name":"libri","x":1069.6671142578125,"y":3506.988067626953,"wires":[["50780f2e.e31f8","930fd299.160f08","95a2d410.fbe098","2a1ea1a8.88ba3e"]]},{"id":"2a1ea1a8.88ba3e","type":"function","z":"16cd4688.876b29","name":"EMPTY","func":"var empty;\\nif ( msg.payload.length > 0 ){\\n empty=0;\\n} else {\\n empty = 1;\\n}\\nmsg.empty = empty;\\nreturn msg;","outputs":1,"noerr":0,"x":1227.1668701171875,"y":3516.1668090820312,"wires":[["314d3f64.3dcbd8"]]},{"id":"314d3f64.3dcbd8","type":"switch","z":"16cd4688.876b29","name":"","property":"empty","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false “,” tot“:” str“},{” t“:” set“,” p“:”有效载荷“,” pt“:” msg“,”至“:” [\\ tmsg.titolo,\\ tmsg。 autore \\ t \\ t]“,” tot“:” jsonata“}],” action“:”“,” property“:”“,” from“:”“,” to“:”“,” reg“: false,“ x”:839.6668090820312,“ y”:3505.1670532226562,“ wires”:[[“” 95314a01.d2eb58“,” ff75b9d0.a297c“]]}},{” id“:” 95314a01.d2eb58“,” type“: “ mysql”,“ z”:“ 16cd4688.876b29”,“ mydb”:“ ac96c738.c838b”,“名称”:“ libri”,“ x”:1069.6671142578125,“ y”:3506.988067626953,“ wires”:[[ “ 50780f2e.e31f8”,“ 930fd299.160f08”,“ 95a2d410.fbe098”,“ 2a1ea1a8.88ba3e”]]},{“ id”:“ 2a1ea1a8.88ba3e”,“ type”:“ function”,“ z”: “ 16cd4688.876b29”,“ name”:“ EMPTY”,“ func”:“ var空; \\ nif(msg.payload.length> 0){\\ n空= 0; \\ n}其他{\\ n空= 1 ; \\ n} \\ nmsg.empty =空; \\ n返回msg;“,”输出“:1,” noerr“:0,” x“:1227.1668701171875,” y“:3516.1668090820312,” wires“:[[” 314d3f64。 3dcbd8“]]},{” id“:” 314d3f64.3dcbd8“,” type“:” switch“,” z“:” 16cd4688.876b29“,” name“:”“,” property“:” empty“, “ propertyType”:“ msg”,“ rules”:[{“ t”:“ eq”,“ v”:“ 0”,“ vt”:“ num”},{“ t”:“ eq”,“ v “:” 1“,” vt“:” num“}],” checkall“:” true“,” repair“:false ,"outputs":2,"x":1370.9447021484375,"y":3514.8334350585938,"wires":[["893d2899.cc8238"],[]]},{"id":"893d2899.cc8238","type":"function","z":"16cd4688.876b29","name":"CICLO FOR MAGAZZINO","func":"var prova = null;\\nvar length = msg.payload.length;\\nfor(var i=0; ,“输出”:2,“ x”:1370.9447021484375,“ y”:3514.8334350585938,“电线”:[[“” d3899.cc8238“],[]]},{” id“:” 893d2899.cc8238“,”类型“:” function“,” z“:” 16cd4688.876b29“,” name“:” CICLO FOR MAGAZZINO“,” func“:” var prova = null; \\ nvar length = msg.payload.length; \\ nfor(var i = 0; i< length; i <长度; i++){\\n var libroInAnalisi = msg.payload[i].idlibro;\\n var magazzino = msg.magazzino;\\n msg.topic = \\"SELECT idlibro FROM magazzino WHERE idmagazzino = \\" + msg.magazzino + \\" AND idlibro = \\" + msg.payload[i].idlibro;\\n prova = msg.paylod; i ++){\\ n var libroInAnalisi = msg.payload [i] .idlibro; \\ n var magazzino = msg.magazzino; \\ n msg.topic = \\“从magazzino中选择idlibro,在idmagazzino = \\” + msg.magazzino + \\“ AND idlibro = \\“ + msg.payload [i] .idlibro; \\ n prova = msg.paylod; /*we can not processed this msg.payload in our for cycle again. / *我们无法在for周期中再次处理此msg.payload。 This result is not processed from the for but is our enter value; 此结果不是从for处理的,而是我们的输入值; we need that this value will be the result of our query */\\n if (prova.length > 0 ) {\\ni = length;\\n return msg;\\n }\\n}\\nreturn msg;\\n \\n\\n","outputs":1,"noerr":0,"x":1598.6668701171875,"y":3506.6106567382812,"wires":[["de18a0fd.f963e"]]},{"id":"de18a0fd.f963e","type":"mysql","z":"16cd4688.876b29","mydb":"ac96c738.c838b","name":"magazzino","x":1841.613037109375,"y":3495.2676391601562,"wires":[["7baa967.2cb4468","d10e16d.0469e68"]]},{"id":"7baa967.2cb4468","type":"debug","z":"16cd4688.876b29","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1925.7799682617188,"y":3383.613235473633,"wires":[]},{"id":"ef4521ef.a299c8","type":"mqtt-broker","z":"","name":"","broker":"iot.eclipse.org","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"ac96c738.c838b","type":"MySQLdatabase","z":"","host":"127.0.0 我们需要此值将是查询* / \\ n的结果,如果(prova.length> 0){\\ ni = length; \\ n return msg; \\ n} \\ n} \\ nreturn msg; \\ n \\ n \\ n“,”输出“:1,” noerr“:0,” x“:1598.6668701171875,” y“:3506.6106567382812,”电线“:[[”“ de18a0fd.f963e”]]}},{“ id”:“ de18a0fd。 f963e“,” type“:” mysql“,” z“:” 16cd4688.876b29“,” mydb“:” ac96c738.c838b“,” name“:” magazzino“,” x“:1841.613037109375,” y“:3495.2676391601562 ,“ wires”:[[“” 7baa967.2cb4468“,” d10e16d.0469e68“]]},{” id“:” 7baa967.2cb4468“,” type“:”调试“,” z“:” 16cd4688.876b29“ ,“ name”:“”,“ active”:true,“ tosidebar”:true,“ console”:false,“ tostatus”:false,“ complete”:“有效载荷”,“ x”:1925.7799682617188,“ y”: 3383.613235473633,“ wires”:[]},{“ id”:“ ef4521ef.a299c8”,“ type”:“ mqtt-broker”,“ z”:“”,“ name”:“”,“ broker”:“ iot.eclipse.org“,”端口“:” 1883“,” clientid“:”“,” usetls“:false,” compatmode“:true,” keepalive“:” 60“,” cleansession“:true,” willTopic “:”“,” willQos“:” 0“,” willPayload“:”“,” birthTopic“:”“,” birthQos“:” 0“,” birthPayload“:”“},{” id“:” ac96c738 .c838b“,” type“:” MySQLdatabase“,” z“:”“,” host“:” 127.0.0 .1","port":"3306","db":"Biblioteca","tz":""}] .1“,” port“:” 3306“,” db“:” Biblioteca“,” tz“:”“}]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM