# Clarification on context stores please

**URL:** <https://discourse.nodered.org/t/clarification-on-context-stores-please/53467>\
**Category:** General\
**Created:** [9 November 2021 18:25 UTC](https://discourse.nodered.org/t/clarification-on-context-stores-please/53467 "2021-11-09T18:25:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HarryPottar](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@HarryPottar](https://discourse.nodered.org/u/HarryPottar)\
**Post date:** [9 November 2021 18:25 UTC](https://discourse.nodered.org/t/clarification-on-context-stores-please/53467/1 "2021-11-09T18:25:40Z")

</div>

Hi.

Using flow context stores, are these unique for each process.

For example: The flow is triggered and flow uses flow context store to keep say count of something, while the flow is running. The flow gets triggered again, so now we have the flow running two different sets of input data. Is the flow context shared between the two flow or is the flow context unique to each process.

Say I was counting some thing, the first process that was triggered is up to 10. the next trigger comes in does that start at 0 or would it add to the existing 10?

Trying to keep flow data but keep it unique for that instance.

Thanks  
Harry

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [9 November 2021 18:33 UTC](https://discourse.nodered.org/t/clarification-on-context-stores-please/53467/2 "2021-11-09T18:33:18Z")

</div>

> [@HarryPottar](#):
>
> Using flow context stores, are these unique for each process

No, in your example you would save the first 'trigger' value to context, for example 10.  
When the second 'trigger' arrives, you would first retrieve the saved value - 10 and then continue adding to it before saving it back again to context.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [9 November 2021 18:35 UTC](https://discourse.nodered.org/t/clarification-on-context-stores-please/53467/3 "2021-11-09T18:35:29Z")

</div>

context data is only unique in scope (node, flow. global), not instance.

if you want to keep a context unique for each count you could do something like this  
`flow.set("count." + unique_id, "some_data")`  
this would produce an object with individual properties for each instance.  
e.g

```auto
{
"count": {
    "id1": 10,
    "id2":16,
    "id_etc": 12
    }
}

```

you would retrieve the individual unique id's with  
`flow.get("count." + unique_id)`  
or all id counts  
`flow.get("count")`

---

<div class="post-metadata">

**Author:** ![HarryPottar](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@HarryPottar](https://discourse.nodered.org/u/HarryPottar)\
**Post date:** [9 November 2021 19:06 UTC](https://discourse.nodered.org/t/clarification-on-context-stores-please/53467/4 "2021-11-09T19:06:34Z")

</div>

Thanks for the feed back, thats what we thought but want clarification. We need to store flow context unique to each trigger. We will use a unique id like the message id or something and delete it once the flow is finished.

Thanks  
Harry

---

<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:** [9 November 2021 21:25 UTC](https://discourse.nodered.org/t/clarification-on-context-stores-please/53467/5 "2021-11-09T21:25:42Z")

</div>

Are you sure you need to use context? Possibly you can save the information you want in a message attribute so that it flows down with the message. Nodes should not change the content of attributes that they do not use (though not all nodes follow this convention).

---

<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:** [23 November 2021 21:26 UTC](https://discourse.nodered.org/t/clarification-on-context-stores-please/53467/6 "2021-11-23T21:26:34Z")

</div>

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