# Read from cloudant db last documents

**URL:** <https://discourse.nodered.org/t/read-from-cloudant-db-last-documents/1927>\
**Category:** Dashboard\
**Created:** [31 July 2018 11:30 UTC](https://discourse.nodered.org/t/read-from-cloudant-db-last-documents/1927 "2018-07-31T11:30:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahd](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@Ahd](https://discourse.nodered.org/u/Ahd)\
**Post date:** [31 July 2018 11:30 UTC](https://discourse.nodered.org/t/read-from-cloudant-db-last-documents/1927/1 "2018-07-31T11:30:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 August 2018 08:21 UTC](https://discourse.nodered.org/t/read-from-cloudant-db-last-documents/1927/3 "2018-08-01T08:21:03Z")

</div>

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](https://nodered.org/docs/writing-functions#storing-data)

---

<div class="post-metadata">

**Author:** ![Ahd](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@Ahd](https://discourse.nodered.org/u/Ahd)\
**Post date:** [2 August 2018 09:26 UTC](https://discourse.nodered.org/t/read-from-cloudant-db-last-documents/1927/4 "2018-08-02T09:26:39Z")

</div>

Thanks,for your help.😀
