Switch on RowDataPacket contents

Struggling to understand how to use a switch node to switch based on the content of a RowDataPacket returned from a SQL Select in a Function Node.

The output from the SQL Select is always a single name / value object

[ RowDataPacket { access: 1 } ]

and access will either be 0 or 1.

The logic is simple, activate output 1 if access = 1

I have ready many posts and some seem to suggest that I need a split node or another function node to split the array before passing the value to the switch node Is this true?

Regards
Ralph

Hi @jaguar

My guess is you can use msg.payload[0].access in the switch node to check that value.

If that doesn't work, can you pass that message to a Debug node and show us how it gets displayed there?

The was just a fix applied to node-red-node-mysql (v0.1.2) that eliminates that issue so that it will always return an array. So RowDataPacketwill not be in the results of a select anymore.

Thanks Knolleary, you are a life-saver.

I am dismayed after many hours struggling with this.

Thanks zenofmud, that's good to know. Someday I may find time to update things instead of struggling all the time.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.