Hi!
I tried to make simple RSS Reader but i encounter the problem where from combined payload i can't use info for dropdown menu filters based on info from sqlite3 database. If i use feeds then no search fields but when i use keywords then i get dropdown values.
Feeds
Keywords
Payload
{"feeds":[{"name":"PC"},{"name":"Saab"},{"name":"Audi"},{"name":"Motocikli"}],"keywords":[{"rowid":1,"expression":"7800x3d","urlname":"","amount_of_money":250},{"rowid":2,"expression":"5800x3d","urlname":"","amount_of_money":200},{"rowid":3,"expression":"4790","urlname":"200","amount_of_money":200},{"rowid":4,"expression":"A7","urlname":"250","amount_of_money":2000}]}
I added flow for checkup
[
{
"id": "c7526823b578902a",
"type": "http in",
"z": "6ae25f92b98f01af",
"name": "",
"url": "/monitor/keyword",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 180,
"y": 380,
"wires": [
[
"94cfdabb822422af"
]
]
},
{
"id": "94cfdabb822422af",
"type": "sqlite",
"z": "6ae25f92b98f01af",
"mydb": "368ac54f1f670f55",
"sqlquery": "fixed",
"sql": "SELECT rowid, * FROM keyword;",
"name": "db_keywords",
"x": 430,
"y": 380,
"wires": [
[
"95a11f7ac06cafd7"
]
]
},
{
"id": "deb19e11db635174",
"type": "sqlite",
"z": "6ae25f92b98f01af",
"mydb": "368ac54f1f670f55",
"sqlquery": "msg.topic",
"sql": "",
"name": "db_feeds",
"x": 800,
"y": 440,
"wires": [
[
"3a86c814640813ee"
]
]
},
{
"id": "3a86c814640813ee",
"type": "function",
"z": "6ae25f92b98f01af",
"name": "combine payloads",
"func": "msg.payload = {\n feeds: msg.payload.toString,\n keywords: msg.keywords\n};\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1010,
"y": 440,
"wires": [
[
"000a53dc418b20b2",
"cdbf57ae58f6a689",
"c4ec1298425a6839"
]
]
},
{
"id": "cb64af9e2e3e4b2d",
"type": "http response",
"z": "6ae25f92b98f01af",
"name": "",
"statusCode": "",
"headers": {},
"x": 1450,
"y": 440,
"wires": []
},
{
"id": "5888906c887c5c35",
"type": "http in",
"z": "6ae25f92b98f01af",
"name": "",
"url": "/monitor/keyword",
"method": "post",
"upload": false,
"swaggerDoc": "",
"x": 180,
"y": 480,
"wires": [
[
"f69fc6e896b4d6e3"
]
]
},
{
"id": "f69fc6e896b4d6e3",
"type": "template",
"z": "6ae25f92b98f01af",
"name": "INSERT",
"field": "topic",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "INSERT INTO keyword (expression, urlname, amount_of_money) VALUES ('{{payload.expression}}', '{{payload.urlname}}', '{{payload.amount_of_money}}')",
"output": "str",
"x": 460,
"y": 480,
"wires": [
[
"867f3b756b1a96d9"
]
]
},
{
"id": "867f3b756b1a96d9",
"type": "sqlite",
"z": "6ae25f92b98f01af",
"mydb": "368ac54f1f670f55",
"sqlquery": "msg.topic",
"sql": "",
"name": "db",
"x": 610,
"y": 500,
"wires": [
[
"94cfdabb822422af"
]
]
},
{
"id": "bff868e7cddc237b",
"type": "http in",
"z": "6ae25f92b98f01af",
"name": "",
"url": "/monitor/keyword/delete/:rowid",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 220,
"y": 540,
"wires": [
[
"f077f85cef0a99a3"
]
]
},
{
"id": "f077f85cef0a99a3",
"type": "template",
"z": "6ae25f92b98f01af",
"name": "DELETE",
"field": "topic",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "DELETE FROM keyword WHERE rowid = {{req.params.rowid}}",
"output": "str",
"x": 460,
"y": 540,
"wires": [
[
"867f3b756b1a96d9"
]
]
},
{
"id": "e0f0302e4d388031",
"type": "comment",
"z": "6ae25f92b98f01af",
"name": "/monitor/keyword",
"info": "",
"x": 160,
"y": 340,
"wires": []
},
{
"id": "95a11f7ac06cafd7",
"type": "function",
"z": "6ae25f92b98f01af",
"name": "combine results",
"func": "let keywords = msg.payload;\n\n// Make a copy of the message to query feeds\nlet newMsg = { ...msg, payload: null, topic: null };\nnewMsg.topic = \"SELECT name FROM feed;\";\nnewMsg.keywords = keywords;\nreturn [null,newMsg];",
"outputs": 2,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 620,
"y": 380,
"wires": [
[],
[
"deb19e11db635174"
]
]
},
{
"id": "000a53dc418b20b2",
"type": "debug",
"z": "6ae25f92b98f01af",
"name": "debug 26",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "keywords",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1260,
"y": 520,
"wires": []
},
{
"id": "c4ec1298425a6839",
"type": "template",
"z": "6ae25f92b98f01af",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<!DOCTYPE html>\n<html>\n<head>\n <link rel=\"stylesheet\" href=\"//cdn.jsdelivr.net/npm/bootswatch@4.5.2/dist/slate/bootstrap.min.css\"\n integrity=\"sha384-8iuq0iaMHpnH2vSyvZMSIqQuUnQA7QM+f6srIdlgBrTSEyd//AWNMyEaSF2yPzNQ\" crossorigin=\"anonymous\">\n <title>Keyword Monitor</title>\n</head>\n<body>\n <div class=\"container\">\n <h1>Keyword Monitor</h1>\n <div class=\"row\">\n <div class=\"col-md-6\">\n <form method=\"POST\" action=\"/monitor/keyword\">\n <label for=\"urlname\">URL Name</label>\n <select class=\"form-control\" id=\"urlname\" name=\"urlname\">\n {{#feeds}}\n <option value=\"{{{name}}}\">{{{name}}}</option>\n {{/feeds}}\n </select>\n <label for=\"urlname2\">URL Name2</label>\n <select class=\"form-control\" id=\"urlname2\" name=\"urlname2\">\n {{#keywords}}\n <option value=\"{{amount_of_money}}\">{{amount_of_money}}</option>\n {{/keywords}}\n </select>\n </form>\n </div>\n </div>\n </div>\n</body>\n</html>\n",
"output": "str",
"x": 1260,
"y": 280,
"wires": [
[
"cb64af9e2e3e4b2d"
]
]
},
{
"id": "cdbf57ae58f6a689",
"type": "debug",
"z": "6ae25f92b98f01af",
"name": "debug 27",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1260,
"y": 360,
"wires": []
},
{
"id": "368ac54f1f670f55",
"type": "sqlitedb",
"db": "/etc/sqlite/monitor.db",
"mode": "RWC"
}
]