Hello,
With the great support of @E1cid I was able to filter a json database (Filter json database with conditions
Now I would like to join two json files to one json file and sort the result file by a select variable (for example price).
My current node red flow look like this
[{"id":"e6926a4555f50a3e","type":"inject","z":"67e5e39e7b6a8e54","name":"","repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":320,"y":1560,"wires":[["d00f26c8017f46e9","87b3ecbe3f2daf0f"]]},{"id":"d00f26c8017f46e9","type":"function","z":"67e5e39e7b6a8e54","name":"set payload and headers","func":"msg.headers = {};\nmsg.headers = {\n};\n\n\nmsg.payload = {};\nmsg.payload = {\n 'region' : 9,\n 'province': 'RM',\n 'town' : 'Monterotondo',\n 'priceOrder':'desc', \n 'fuelType': '1-1',\n 'refuelingMode': 1\n};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":1560,"wires":[["1d8bb51c38acb99a"]]},{"id":"1d8bb51c38acb99a","type":"http request","z":"67e5e39e7b6a8e54","name":"post to HttpBin","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://carburanti.mise.gov.it/ospzApi/search/area","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":720,"y":1560,"wires":[["0a4e9c551c73218d","89f87e77215f7336","aab2cfb4326f6be6"]]},{"id":"0a4e9c551c73218d","type":"debug","z":"67e5e39e7b6a8e54","name":"debug 201","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":1540,"wires":[]},{"id":"89f87e77215f7336","type":"change","z":"67e5e39e7b6a8e54","name":"","rules":[{"t":"set","p":"fuelId","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"name","pt":"msg","to":"Benzina","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"($$.payload.results{\t $.name: {\t \"name\": $.name,\t \"fuels\": [$.fuels[$.fuelId = $$.fuelId and $.name = $$.name]],\t \"insertDate\":$.insertDate\t }\t}).*[$exists($.fuels[0])]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":1680,"wires":[["be1bf5946d6e9650","c6137e1d72f2da72"]]},{"id":"be1bf5946d6e9650","type":"template","z":"67e5e39e7b6a8e54","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{#payload}}\nName company: {{name}}\n-------------\n{{#fuels}}\nprice: {{price}}\nfuel: {{name}}\nisSelf: {{isSelf}}\n-------------\n{{/fuels}}\nDate and time: {{insertDate}}\n______________\n\n{{/payload}}\n{{^payload}}No Result for\nname: {{name}}\nfuelId: {{fuelId}}{{/payload}}","output":"str","x":740,"y":1680,"wires":[["89cad60e79bf2836"]]},{"id":"c6137e1d72f2da72","type":"debug","z":"67e5e39e7b6a8e54","name":"debug 203","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":1760,"wires":[]},{"id":"89cad60e79bf2836","type":"debug","z":"67e5e39e7b6a8e54","name":"debug 199","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":1680,"wires":[]},{"id":"87b3ecbe3f2daf0f","type":"function","z":"67e5e39e7b6a8e54","name":"set payload and headers","func":"msg.headers = {};\nmsg.headers = {\n};\n\n\nmsg.payload = {};\nmsg.payload = {\n 'region' : 9,\n 'province': 'RM',\n 'town' : 'Agosta',\n 'priceOrder':'desc', \n 'fuelType': '1-1',\n 'refuelingMode': 1\n};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":1900,"wires":[["d511023821c3a924"]]},{"id":"d511023821c3a924","type":"http request","z":"67e5e39e7b6a8e54","name":"post to HttpBin","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://carburanti.mise.gov.it/ospzApi/search/area","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":740,"y":1900,"wires":[["89c23c9e7df590a6","b3046250be4cc311","aab2cfb4326f6be6"]]},{"id":"89c23c9e7df590a6","type":"debug","z":"67e5e39e7b6a8e54","name":"debug 217","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":1880,"wires":[]},{"id":"b3046250be4cc311","type":"change","z":"67e5e39e7b6a8e54","name":"","rules":[{"t":"set","p":"fuelId","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"name","pt":"msg","to":"Benzina","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"($$.payload.results{\t $.name: {\t \"name\": $.name,\t \"fuels\": [$.fuels[$.fuelId = $$.fuelId and $.name = $$.name]],\t \"insertDate\":$.insertDate\t }\t}).*[$exists($.fuels[0])]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":2020,"wires":[["906ea31eae12fee7","1d5da510e5110d93"]]},{"id":"906ea31eae12fee7","type":"template","z":"67e5e39e7b6a8e54","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{#payload}}\nName company: {{name}}\n-------------\n{{#fuels}}\nprice: {{price}}\nfuel: {{name}}\nisSelf: {{isSelf}}\n-------------\n{{/fuels}}\nDate and time: {{insertDate}}\n______________\n\n{{/payload}}\n{{^payload}}No Result for\nname: {{name}}\nfuelId: {{fuelId}}{{/payload}}","output":"str","x":760,"y":2020,"wires":[["551c0407369f8d41"]]},{"id":"1d5da510e5110d93","type":"debug","z":"67e5e39e7b6a8e54","name":"debug 218","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":2100,"wires":[]},{"id":"551c0407369f8d41","type":"debug","z":"67e5e39e7b6a8e54","name":"debug 219","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":2020,"wires":[]},{"id":"aab2cfb4326f6be6","type":"join","z":"67e5e39e7b6a8e54","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"0","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":470,"y":2260,"wires":[["b6a83593b4551f9f","27a1795543c05c1d"]]},{"id":"b6a83593b4551f9f","type":"change","z":"67e5e39e7b6a8e54","name":"","rules":[{"t":"set","p":"fuelId","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"name","pt":"msg","to":"Benzina","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"($$.payload.results{\t $.name: {\t \"name\": $.name,\t \"fuels\": [$.fuels[$.fuelId = $$.fuelId and $.name = $$.name]],\t \"insertDate\":$.insertDate\t }\t}).*[$exists($.fuels[0])]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":2260,"wires":[["643e4cdfda6c0da0"]]},{"id":"643e4cdfda6c0da0","type":"debug","z":"67e5e39e7b6a8e54","name":"debug 220","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":2260,"wires":[]},{"id":"44758031a002dade","type":"template","z":"67e5e39e7b6a8e54","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{#payload}}\nName company: {{name}}\n-------------\n{{#fuels}}\nprice: {{price}}\nfuel: {{name}}\nisSelf: {{isSelf}}\n-------------\n{{/fuels}}\nDate and time: {{insertDate}}\n______________\n\n{{/payload}}\n{{^payload}}No Result for\nname: {{name}}\nfuelId: {{fuelId}}{{/payload}}\n\n\n","output":"str","x":960,"y":2380,"wires":[["8fa654d6fa901096"]]},{"id":"8fa654d6fa901096","type":"debug","z":"67e5e39e7b6a8e54","name":"debug 208","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1150,"y":2380,"wires":[]},{"id":"27a1795543c05c1d","type":"change","z":"67e5e39e7b6a8e54","name":"","rules":[{"t":"set","p":"name","pt":"msg","to":"Gasolio","tot":"str"},{"t":"set","p":"fuelId","pt":"msg","to":"2","tot":"num"},{"t":"set","p":"isSelf","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"($$.payload.results{\t \"name\": $.name,\t \"fuels\": [$.fuels[$.fuelId = $$.fuelId and $.name = $$.name and $.isSelf = $$.isSelf]],\t \"insertDate\":$.insertDate\t })","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":2380,"wires":[["44758031a002dade","5df0dd3028b87836","47399c1d046c9895"]]},{"id":"5df0dd3028b87836","type":"debug","z":"67e5e39e7b6a8e54","name":"debug 221","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":2460,"wires":[]},{"id":"47399c1d046c9895","type":"ui_table","z":"67e5e39e7b6a8e54","group":"e291a9746f2f79dd","name":"","order":0,"width":0,"height":0,"columns":[{"field":"name","title":"company","width":"","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"price","title":"Price","width":"","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}}],"outputs":0,"cts":false,"x":1150,"y":2300,"wires":[]},{"id":"e291a9746f2f79dd","type":"ui_group","name":"Default","tab":"fdfa5af28343e428","order":1,"disp":true,"width":"10","collapse":false,"className":""},{"id":"fdfa5af28343e428","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
At the moment I have problems with the correct display of the results data:
Unfortunately it will displayed all company names and then all other data but not company-price-company-price for example. I tried to understand this description.
I was not able to find the correct way to display the data correctly.
In addition I would like to sort the merged file. For example i would like to sort the data by the price downwards. I have not an idea how can I do this...
Has someone an idea where can I find info for the mentioned topics (for example link or book)?
I am a newbie with node red and so I hope someone can help me to resolve the task.
Thank you in advance.