How to check the status of a second MongoDB collection in a Node-RED function node to avoid sending duplicate messages?

Am new to node-red and need some help…
I have 2 mongodb collections:

  • Collection1: Contains a list of messages/alerts to be sent (I am using MQTT to send the messages).
  • Collection2: Contains status about whether a message has been sent or not.

Initially, the status flag is set to False. In one of my function nodes, I read from Collection1 and send an alert message. Once an alert is sent, I log the status (status flag is set to True) on Collection2.

In this function, I want to check and write ONLY if the message HAS NOT been already sent, by using the status available in second collection (collection2).

How do I check the status of the second collection inside the function? The node-red flow is present in the attached image.

node red flow

I have tried joining the nodes, using fusion as well, but no luck on this. Can anyone help?

Read more here: Source link