# Reading data from database and sending to uibuilder

**URL:** <https://discourse.nodered.org/t/reading-data-from-database-and-sending-to-uibuilder/66432>\
**Category:** General\
**Tags:** uibuilder\
**Created:** [15 August 2022 05:49 UTC](https://discourse.nodered.org/t/reading-data-from-database-and-sending-to-uibuilder/66432 "2022-08-15T05:49:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![miladmrm](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@miladmrm](https://discourse.nodered.org/u/miladmrm)\
**Post date:** [15 August 2022 05:49 UTC](https://discourse.nodered.org/t/reading-data-from-database-and-sending-to-uibuilder/66432/1 "2022-08-15T05:49:41Z")

</div>

I am developing a dashboard in uibuilder. Some of my data should be stored in the database and read from the database and displayed on the dashboard. I have no problem when storing data (I take the relevant output from uibuilder and save it). My problem is reading the data. I read the data from the database and send it to uibuilder, but I use inject node and it's a bit unusual that I activate inject node first and then see the data in my dashboard!  
Actually, I want to completely separate the access of my uibuilder from the NR and the user who uses the uibuilder does not have access to the NR.

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [15 August 2022 07:14 UTC](https://discourse.nodered.org/t/reading-data-from-database-and-sending-to-uibuilder/66432/2 "2022-08-15T07:14:13Z")

</div>

You can use the second output of uibuilder node (lowest), to catch the `uibuilderCtrl` message, check it for "`client connect`" and use it as a trigger to NR to retrieve data from your database. Non need for the inject node, as the `uibuilderCtrl` message is sent each time the client gets connected to NR.

 ![Schermata 2022-08-15 alle 09.12.17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c780ada6796a063cbef568a28823d38b0eb2c0af.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 August 2022 08:23 UTC](https://discourse.nodered.org/t/reading-data-from-database-and-sending-to-uibuilder/66432/3 "2022-08-15T08:23:34Z")

</div>

Yes, you can use that to automate initial delivery of data.

Of course, you can also put a simple button on your UI that sends a message to uibuilder that you use to trigger your db query manually.

---

<div class="post-metadata">

**Author:** ![miladmrm](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@miladmrm](https://discourse.nodered.org/u/miladmrm)\
**Post date:** [16 August 2022 07:00 UTC](https://discourse.nodered.org/t/reading-data-from-database-and-sending-to-uibuilder/66432/4 "2022-08-16T07:00:12Z")

</div>

Thanks all,  
I handled this issue in page reload by `window.PerformanceNavigation.TYPE_RELOAD`

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 August 2022 08:41 UTC](https://discourse.nodered.org/t/reading-data-from-database-and-sending-to-uibuilder/66432/5 "2022-08-16T08:41:04Z")

</div>

> [@miladmrm](#):
>
> window.PerformanceNavigation.TYPE\_RELOAD

> **Deprecated:** This feature is no longer recommended

> Use the [`PerformanceNavigationTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming) interface instead.

From MDN.

But I don't understand why you would do that anyway, if you want to do something when the client loads the document, simply put it at the start of your index.js script.

But as mentioned, this is not necessary as you can do it from node-red.

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [16 August 2022 09:28 UTC](https://discourse.nodered.org/t/reading-data-from-database-and-sending-to-uibuilder/66432/6 "2022-08-16T09:28:25Z")

</div>

> [@TotallyInformation](#):
>
> But I don't understand why you would do that anyway, if you want to do something when the client loads the document, simply put it at the start of your index.js script.

or - if you use Vue - you can put any code that must run at start into `mounted: function () { }`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 October 2022 09:28 UTC](https://discourse.nodered.org/t/reading-data-from-database-and-sending-to-uibuilder/66432/7 "2022-10-15T09:28:41Z")

</div>

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