Read from cloudant db last documents

Hi all
I am new to node red, I will appreciate your help and guidance, please.

I am working on flow in node red, this flow has three function nodes:
founction1 received data from temp a sensor and function 2 is received data from temp a sensor, then both of them send messages payload to function 3. After that function 3 insert the data to cloudant db node. I want to read only the last documents for both sensors then compare the reading. Any advice or help will be appreciated

First make sure the messages from functions 1 and 2 have different topics. Then you can use a Join node to combine the payloads into one message containing a key/value pairs using the topics as keys, then you can access those in function 3. Alternatively in function 3 you can save the previous values in the node's local context so that you can compare them. See https://nodered.org/docs/writing-functions#storing-data

1 Like

Thanks,for your help.:grinning: