I have two sql queries that i want to run against the same database. I want to combine the results of the two queries into a single object, so that i can use it in a html template further down the road.
Running them both separately works as expected and returns an object with the correct data from the database.
Below is a screenshot of the Node-RED flow.
In my combine function i have tried the following code but it just gives me two separate arrays, that contain one object:
var myArray = [];
var ob = {};
for(var i = 0; i < msg.payload.length; i++){
ob = msg.payload[i];
myArray.push(ob);
}
msg.topic = myArray;
return msg
I believe this is because the queries are executed one after the other. Is there a way to execute them at the same time and store the result?
Replace your combine
function node with a join node set it to join on when it receives 2 messages and if you play around with the options it should be able to join the 2 arrays