Creating a table with a certain number of rows

Hello guys, i wish everyone is ok.

i have a project that consist me to create a table which it should be fill in with data(rows); The data is extracted from a database node with the help of a function node and an inject node(that sends a payload every 5 seconds).
The only problem i'm facing is that i want the table to stop incrementing at a certain number of rows, for example if the 135th row of the table is reached, the table node should stop extracting data from the database node, and after that when i click on a button reset, this button will make be able to clean the table from the oldest rows and begin with injecting new rows with new data values inserted in each column.
i'm very stuck with this problem, i really need the help of someone and until now i tried many propositions of solutions but nothing worked.(i'm just a beginner in node red and i wish to learn it very good , so i think this is a start).

thank you in advance for your replies.

Welcome to the forum @oussama5

Is the database query fetching the last row in the database each time or is it selecting particular rows?

Thank you @Colin for your fast reply.

Actually,the database node is wiring up with a function that sends a message topic that contains this query:
select avg(case when stationmétéorologique.timestamp > now() - interval 1 day then directiondevent end) avgdirectiondevent,avg(case when stationmétéorologique.timestamp > now() - interval 1 day then lumiere end) avglumiere,avg(case when stationmétéorologique.timestamp > now() - interval 1 day then directiondevent end) avgvitessedevent,avg(case when stationmétéorologique.timestamp > now() - interval 1 day then pression end) avgpressure,max(case when stationmétéorologique.timestamp > now() - interval 1 day then temperature end) max, min(case when stationmétéorologique.timestamp > now() - interval 1 day then temperature end) min, avg(case when stationmétéorologique.timestamp > now() - interval 1 day then temperature end) as average, max(case when stationmétéorologique.timestamp > now() - interval 1 day then pression end) maxpression, min(case when stationmétéorologique.timestamp > now() - interval 1 day then pression end) minpression, max(case when stationmétéorologique.timestamp > now() - interval 1 day then moisture end) maxmoisture, min(case when stationmétéorologique.timestamp > now() - interval 1 day then moisture end) minmoisture, max(case when stationmétéorologique.timestamp > now() - interval 1 day then vitessedevent end) maxvitessedevent, min(case when stationmétéorologique.timestamp > now() - interval 1 day then vitessedevent end) minvitessedevent, avg(case when stationmétéorologique.timestamp > now() - interval 1 day then vitessedevent end) avgvitessedevent, avg(case when stationmétéorologique.timestamp > now() - interval 1 day then precipitation end) avgprecipitation, avg(case when stationmétéorologique.timestamp > now() - interval 1 day then moisture end) avgmoisture1, avg(case when capteurnpk.timestamp > now() - interval 1 day then SoilMoisture end) avgmoisture from gtcep.stationmétéorologique,gtcep.capteurnpk where stationmétéorologique.timestamp > now() - interval 30 day OR capteurnpk.timestamp > now() - interval 30 day ".

This last query allow me to have the average of a multiple data column for the last 24hours.

and i want in the finish of each day at 23h59, that the Database node should be commanded to send new averages of the data , and inject them in a new row at the bottom of the table.

You could use node-red-contrib-simple-gate to allow our block the requests

i have just tried it now, but unfortunately it doesn't solve the problem alone.

i think if i want to create a table, i should use the node template but i don't know how to inject the rows of data in it regarding the conditions that i have indicated in my reply before.

in this case i think , i should use a function before the template but i don't know how to write the code even of i tried several possible codes but it doesn't work with the way i want.
what do you think @Colin ?

You said in the first post

Is that not correct? I was helping you to find the answer to that problem. I have never used the ui_table node (I presume that is what you are talking about) so can't help with that bit of the problem, sorry.

As you are an absolute beginner I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. It may not specifically answer you current problem but you will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

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