Hi, I'm having trouble getting data from a form and using node-red.
I created a form using node-red and I need to save the filled data in the form in pgadmin.
Can someone help me?
//export nodes to clipboard:
[{"id":"e6dd69fb.058f48","type":"subflow","name":"postgres","info":"","in":[{"x":180,"y":200,"wires":[{"id":"8c1f9f8b.d87c5"},{"id":"58b59ce1.757a34"}]}],"out":[{"x":860,"y":220,"wires":[{"id":"a58f879e.f4f9c8","port":0}]}]},{"id":"8c1f9f8b.d87c5","type":"function","z":"e6dd69fb.058f48","name":"sqlIN","func":"flow.set('queue',true);\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":180,"wires":[["142c22e9.0a05fd"]]},{"id":"a58f879e.f4f9c8","type":"function","z":"e6dd69fb.058f48","name":"sqlOUT","func":"if(flow.get('queue')){\n var bdResponse = {\n payload : {\n Success : false,\n Count : 0,\n Data : {},\n Message : {}\n }\n };\n bdResponse.queryParameters = msg.queryParameters;\n if(!msg.hasOwnProperty('error')){\n if(!msg.payload.includes('error')){\n if(!msg.payload.includes('Error')){\n if(Array.isArray(msg.payload)){\n bdResponse.payload.Success = true;\n bdResponse.payload.Count = msg.payload.length;\n bdResponse.payload.Data = msg.payload;\n }\n }else{\n bdResponse.payload.Message = msg.payload;\n }\n }else{\n bdResponse.payload.Message = msg.payload;\n }\n }else{\n bdResponse.payload.Message = msg.error;\n }\n \n flow.set('queue',false);\n return bdResponse;\n}\n \n","outputs":1,"noerr":0,"x":720,"y":220,"wires":[[]]},{"id":"10440874.97c4f8","type":"catch","z":"e6dd69fb.058f48","name":"catchBD","scope":["3896971b.81ed88","58b59ce1.757a34","142c22e9.0a05fd","8c1f9f8b.d87c5","a58f879e.f4f9c8"],"x":500,"y":260,"wires":[["a58f879e.f4f9c8"]]},{"id":"3896971b.81ed88","type":"delay","z":"e6dd69fb.058f48","name":"bdTimeout","pauseType":"delayv","timeout":"15","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":530,"y":220,"wires":[["a58f879e.f4f9c8"]]},{"id":"58b59ce1.757a34","type":"function","z":"e6dd69fb.058f48","name":"bdTimeout","func":"var bdTimeout = {\n payload : {},\n error : 'database timeout',\n delay : msg.delay || 5000\n};\nreturn bdTimeout;","outputs":1,"noerr":0,"x":350,"y":220,"wires":[["3896971b.81ed88"]]},{"id":"142c22e9.0a05fd","type":"postgres","z":"e6dd69fb.058f48","postgresdb":"44f479a7.5ce328","name":"127.0.0.1","output":true,"outputs":1,"x":540,"y":180,"wires":[["a58f879e.f4f9c8"]]},{"id":"44f479a7.5ce328","type":"postgresdb","z":"","hostname":"127.0.0.1","port":"5432","db":"gcf_offline","ssl":false},{"id":"e62a7624.fea5f8","type":"function","z":"3efcb770.e0afa8","name":"COPIA CONFIGURAÇÕES","func":"let config = flow.get(\"configuracoes_nuvem\");\nlet maquina = flow.get(\"maquina\");\nlet atualizar = flow.get(\"atualizarConfiguracoes\");\n\n\nif(msg.atualizar === true || msg.payload.Success === true){\n let queryInsert = \"\";\n \n let startQuery = \"INSERT INTO \";\n let tableName = \"checklist_rotina_configuracoes\";\n let middleQuery = \" VALUES (\"\n let endQuery = \");\\n\"\n \n config.Data.forEach(element => {\n queryInsert += \n startQuery + \n tableName + \n middleQuery + \n \"'\" + element.maquina + \"',\" +\n \"'\" + element.item + \"',\" +\n element.qrcode + \",\" +\n \"'\" + element.horario + \"'\" +\n endQuery;\n });\n msg.atualizar = true;\n msg.payload = queryInsert;\n return msg;\n}\n\nreturn msg;","outputs":"1","noerr":0,"x":340,"y":340,"wires":[["a6216706.e9cdc8"]]},{"id":"a6216706.e9cdc8","type":"switch","z":"3efcb770.e0afa8","name":"ATUALIZAR CONFIGURAÇÕES?","property":"atualizar","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","outputs":2,"x":640,"y":340,"wires":[[],["7b77b262.464e5c"]]},{"id":"e99a2dcb.88001","type":"template","z":"3efcb770.e0afa8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"INSERT INTO public.workstation_pointing_teste(\n\tid, id_gcf, pointing_id, key, value, description, sync)\n\tVALUES (02, 1010, 2020, 'Fornecedor', 'PARANAPANEMA', null, true);","x":590,"y":280,"wires":[["7b77b262.464e5c","53bf162c.2fef38"]]},{"id":"53bf162c.2fef38","type":"debug","z":"3efcb770.e0afa8","name":"","active":true,"console":"false","complete":"payload","x":850,"y":280,"wires":[]},{"id":"bdb5e284.1ed4b","type":"debug","z":"3efcb770.e0afa8","name":"","active":true,"console":"false","complete":"false","x":1090,"y":340,"wires":[]},{"id":"7b77b262.464e5c","type":"subflow:e6dd69fb.058f48","z":"3efcb770.e0afa8","name":"","x":940,"y":340,"wires":[["bdb5e284.1ed4b"]]},{"id":"7e37985d.79d988","type":"inject","z":"3efcb770.e0afa8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":220,"y":280,"wires":[["7455108e.a732e"]]},{"id":"7455108e.a732e","type":"ui_template","z":"3efcb770.e0afa8","group":"f93af55d.5ff468","name":"MP","order":4,"width":0,"height":0,"format":"<!DOCTYPE html>\n<html lang=\"pt-br\">\n<head>\n<style type=\"text/css\">\n\ntd,\nth {\n border: 1px solid;\n padding: 10px;\n}\n\ntd {\n text-align: center;\n}\n\ntr:nth-child(even) {\n background-color: #eee;\n}\ntable id{\n border-collapse: collapse;\n border: 2px solid rgb(150, 150, 150);\n letter-spacing: 1px;\n font-family: sans-serif;\n font-size: .8rem;\n}\n\ntable id\n\n.fonte{\n width: auto;\n text-align: center;\n border: 3px solid black;\n font-size: 5px;\n}\n\n{\n float:left;\n}\n.header{\n width: auto;\n text-align: center;\n border: 3px solid black;\n font-size: 20px;\n}\n.formulario{\n width: 400px;\n padding: 30px;\n border-style: solid;\n border-color: #FFD700;\n border-radius:40px;\n box-shadow: 10px 10px 10px 5px black;\n}\n.formulario p{\n width: 100%;\n font-size: 1.5em;\n border-width: medium;\n border-style: solid;\n border-radius:5px;\n}\n.field{\n width: auto;\n margin: 20px;\n border-width: medium;\n border-radius:5px;\n}\n.field label{\n width: auto;\n display: inline-block;\n border-width: medium;\n}\n.button{\n width: auto;\n text-align: center;\n border: 1px solid #eee;\n font-size: 18px;\n border-radius:10px;\n}\n\n}\n.field:hover {\nbackground: #F0F8FF;\n}\n</style>\n <title>Data</title>\n <meta charset=\"utf-8\"/>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"estilo.css\">\n</head>\n<body>\n \n <form class=\"formulario\" id=\"jumbo\" method=\"post\"> \n \n <div class=\"header\">\n <h1> Matéria Prima - Vergalhão</h1>\n </div> \n\n <div class=\"field\">\n <label for=\"nome\">Fornecedor:</label>\n <input type=\"text\" id=\"fornecedor\" value=\"\" name=\"fornecedor\" placeholder=\"fornecedor\" required=\"required\">\n </div>\n \n <div class=\"field\">\n <label for=\"lote\">Lote:</label>\n <input type=\"text\" id=\"loteid\" name=\"lote\" placeholder=\"Digite o Lote da MP\" required=\"required\">\n </div>\n \n <div class=\"field\">\n <label for=\"date\">Data:</label>\n <input type=\"datetime-local\" name=\"time\" required=\"required\">\n </div>\n \n <div class=\"field\">\n <input type=\"reset\">\n </div>\n \n <div class=\"button\">\n <input type=\"submit\" name=\"save\" value=\"Salvar MP\">\n </div>\n\n </form>\n \n <script>\n function fornecedor(){\n var input = document.querySelector(\"fornecedor\");\n\n var texto = input.value;\n \n console.log(texto);\n \n return true;\n }\n \n (function(scope) {\n scope.$watch('msg.payload', function(data) {\n if(data) {\n document.getElementById('fornecedor').innerHTML = data.fornecedor;\n }\n });\n })(scope);\n </script>\n \n</body>\n</html>\n\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":410,"y":280,"wires":[["e99a2dcb.88001"]]},{"id":"f93af55d.5ff468","type":"ui_group","z":"","name":"Header","tab":"741e5b0d.bdd684","order":1,"disp":false,"width":"30","collapse":false},{"id":"741e5b0d.bdd684","type":"ui_tab","z":"","name":"Dashboard Operacional","icon":"dashboard","order":1,"disabled":false,"hidden":false}]