# Storing an index by a counter

**URL:** <https://discourse.nodered.org/t/storing-an-index-by-a-counter/6808>\
**Category:** General\
**Created:** [14 January 2019 20:46 UTC](https://discourse.nodered.org/t/storing-an-index-by-a-counter/6808 "2019-01-14T20:46:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabien](https://avatars.discourse-cdn.com/v4/letter/f/85e7bf/32.png) [@fabien](https://discourse.nodered.org/u/fabien)\
**Post date:** [14 January 2019 20:46 UTC](https://discourse.nodered.org/t/storing-an-index-by-a-counter/6808/1 "2019-01-14T20:46:51Z")

</div>

hello, I will need help,  
the goal of the program is to store a counter index to prevent each node red start or redeploy, indexe starts to zero.  
I tried several solutions without success  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d562b9254b2fc0e7f00a3950c5322278f3f33b3c.png)

the storage keeps the value of the idex in memory and changes it into a topic.  
if the starting index is1 (initialization) then take the Topic.  
But it does not work.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/02ee3d2c36f8e8e3157f5d60fe99c5a7f0006b2a.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/88e2940060a8be3c2b46db8542928f52f5987f53.png)

this is what happens after a redeployment

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4c96268b1e5e18353cf0793fce94fb7b7f618e41.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 January 2019 22:16 UTC](https://discourse.nodered.org/t/storing-an-index-by-a-counter/6808/2 "2019-01-14T22:16:46Z")

</div>

Might I suggest yu read the documentation about context - It may give you some ideas  
[https://nodered.org/docs/user-guide/context](https://nodered.org/docs/user-guide/context) and [this thread](https://discourse.nodered.org/t/a-guide-to-understanding-persistent-context/4115) might help
