# Saving informations

**URL:** <https://discourse.nodered.org/t/saving-informations/2668>\
**Category:** General\
**Created:** [29 August 2018 17:37 UTC](https://discourse.nodered.org/t/saving-informations/2668 "2018-08-29T17:37:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![leomozzer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leomozzer/32/1783_2.png) [@leomozzer](https://discourse.nodered.org/u/leomozzer)\
**Post date:** [29 August 2018 17:37 UTC](https://discourse.nodered.org/t/saving-informations/2668/1 "2018-08-29T17:37:05Z")

</div>

I need to save some inputs of a user, its date, a name, start time and finish time. But don't know where to store. Is it a good idea to make a vector for each variable? This vector must grow each time that I put the information that I need. Or I need to create a table and add the variables in the rows?

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [29 August 2018 17:42 UTC](https://discourse.nodered.org/t/saving-informations/2668/2 "2018-08-29T17:42:23Z")

</div>

A database would be the easiest option, I would try mysql or sqlite.

---

<div class="post-metadata">

**Author:** ![leomozzer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leomozzer/32/1783_2.png) [@leomozzer](https://discourse.nodered.org/u/leomozzer)\
**Post date:** [29 August 2018 18:00 UTC](https://discourse.nodered.org/t/saving-informations/2668/3 "2018-08-29T18:00:47Z")

</div>

I created my entire project from an app of blue mix (IBM) and already have a DB there on blue mix, and already made the integration with the nodes. Can I use this DB?

---

<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:** [29 August 2018 20:26 UTC](https://discourse.nodered.org/t/saving-informations/2668/4 "2018-08-29T20:26:14Z")

</div>

A couple of questions.  
Is this set of data going to grow forever or can you say it will never be more entries than some number - maybe 10, or maybe 10 million.  
Does it need to be remembered over reboot/node red restart etc?

---

<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:** [29 August 2018 20:27 UTC](https://discourse.nodered.org/t/saving-informations/2668/5 "2018-08-29T20:27:59Z")

</div>

> [@leomozzer](#):
>
> I created my entire project from an app of blue mix (IBM) and already have a DB there on blue mix, and already made the integration with the nodes. Can I use this DB?

That is something we can ask you, not something you can ask us.

---

<div class="post-metadata">

**Author:** ![leomozzer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leomozzer/32/1783_2.png) [@leomozzer](https://discourse.nodered.org/u/leomozzer)\
**Post date:** [29 August 2018 20:32 UTC](https://discourse.nodered.org/t/saving-informations/2668/6 "2018-08-29T20:32:48Z")

</div>

If the date stored is less than the current date, the values related os this date (time and name) can be discarded

---

<div class="post-metadata">

**Author:** ![leomozzer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leomozzer/32/1783_2.png) [@leomozzer](https://discourse.nodered.org/u/leomozzer)\
**Post date:** [29 August 2018 20:33 UTC](https://discourse.nodered.org/t/saving-informations/2668/7 "2018-08-29T20:33:50Z")

</div>

Yeah, its possible, just need to learn how to add the values.

---

<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:** [29 August 2018 20:40 UTC](https://discourse.nodered.org/t/saving-informations/2668/8 "2018-08-29T20:40:19Z")

</div>

> [@leomozzer](#):
>
> If the date stored is less than the current date, the values related os this date (time and name) can be discarded

You haven't said how many there are likely to be or whether the data has to be retained over restart.

---

<div class="post-metadata">

**Author:** ![leomozzer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leomozzer/32/1783_2.png) [@leomozzer](https://discourse.nodered.org/u/leomozzer)\
**Post date:** [29 August 2018 20:47 UTC](https://discourse.nodered.org/t/saving-informations/2668/10 "2018-08-29T20:47:42Z")

</div>

Have a way to get the current date in my flow?

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [29 August 2018 21:43 UTC](https://discourse.nodered.org/t/saving-informations/2668/11 "2018-08-29T21:43:32Z")

</div>

One way, using a change node:  
 ![Screenshot%20at%202018-08-29%2022-42-23](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/252a31a3a5d55ec3ae552351a94f510f91394810.png)

---

<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:** [30 August 2018 08:02 UTC](https://discourse.nodered.org/t/saving-informations/2668/12 "2018-08-30T08:02:24Z")

</div>

Also an Inject node will give you the current time if set to Timestamp mode. You can set this to regularly inject so you can get a message containing the time every minute, or second, or whatever you need.  
Obviously if you are in a function node you can use the javascript function  
`let now = Date.now()`  
to get the time.

---

<div class="post-metadata">

**Author:** ![leomozzer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leomozzer/32/1783_2.png) [@leomozzer](https://discourse.nodered.org/u/leomozzer)\
**Post date:** [30 August 2018 20:38 UTC](https://discourse.nodered.org/t/saving-informations/2668/13 "2018-08-30T20:38:18Z")

</div>

Worked using the db, and made a simple code to add from there. Thnx. Next step is verify the date. I will make a variable that save the time, and next execute the code below, if date\_saved \< new date, and delete all the information of the db related from the old date.

var date = new Date(msg.payload);

msg.payload = date.toString();

return msg;
