Thanks all,
The two methods high lighted in yellow works.
good stuff.
NOTE - the "hacky" version i posted is identical to the JSON --> JSON version (in that the JSON nodes pretty much do JSON.stringify
--> JSON.parse
under the hood)
I would recommend the first solution over stringify/parse (if it works)
could you also test....
var rows = msg.payload.map((result) => ({
...result,
}));
for (let i=0; i<rows.length; i++) {
node.send({payload: rows[i]})
}
return null
Just to be clear, although the output of the split
node (after the mysql
node) looks like [Object object] when sent to a debug
node displaying 'msg.payload', the data is in the msg and can be accessed, the function
node is not needed. If you change the debug
node to display the 'Complete msg object' you will see all the data.
I am on v1.2.9, where do you select 'Complete msg object'?
Thank you
... though if the end result is to plot on the worldmap then the function could actually map the property names into new objects at the same time... but ok yeah one step at a time.
That is is what the grand master architecture for the flow is at the end of the day,
So now map msg.payload.tl_lat and msg.payload.tl_lon to msg.payload.lat and msg.payload.lon
And sen_id to name. (And maybe add icon and iconColor. )
@ScheepersJohan Johan, just to let you know. there is a new version of node-red-node-mysql (v0,1,2) where the RowDataPacket objects
issue has been fixed so you won't see the [Object object]
in a debug showing only msg.payload..
Thank I will update.
A Function node with this code
let outputMsgs = [];
let parts = msg.payload;
for (var part in parts) {
outputMsgs.push({payload:parts[part]});
}
return [ outputMsgs ];
//The [ ] arround the array 'outputMsgs' sends each item in the array as an own message.
@berijan a split
node will also split the array into seperate messages.
Yes I know about the Split-node but when browsing through the tread understood it as TS tried the Split without success therefore I suggested to try the Function node.
Yes that was the original problem, but the fix in v0.1.2 of the MySQL
node takes care of it.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.