Loop query array and send to mysql

I have array of query
obraz
I try sent msg.topic to mysql like this
obraz
but it send me only one query
obraz
How to loop query as msg.topic and send to mysql ?

you can have only 1 return statement in a function.

I assume that query.length comes from msg.query.length.
But in order to send messages within a loop use node.send({ msg.topic: query[i] })
and add return null at the bottom

To make it shorter:

msg.query.forEach(query => node.send({topic: query}))
return null
1 Like

Not exactly true, you can have many but as soon as one is executed the function node will exit and the flow will move to the next node.

1 Like

Yes sorry indeed that is a better formulation; return = exit

Kind of weird, because I use that all the time in "guard clauses"

1 Like

Yes sorry indeed that is a better formulation; return = exit
I try 'return exit' 'exit' 'return = exit' and its fault.
What is the correct?

It just means that any return statement will exit the function and / or function node

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