# Problems deleting items in global context

**URL:** https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310
**Category:** General
**Created:** [11 February 2025 10:04 UTC](https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310 "2025-02-11T10:04:08Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![wwyyrrmm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wwyyrrmm/32/75728_2.png) [@wwyyrrmm](https://discourse.nodered.org/u/wwyyrrmm)
#### Post date: [11 February 2025 10:04 UTC](https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310/1 "2025-02-11T10:04:09Z")

</div>

I have too much entries in the global context ("file") stored.  
I want to delete them by hand in the .node-red/context/global/global.json  
with node-red-stop  
the memory shoud be flushed to file  
with  
sudo nala I have deleted the no longer desired items in global.json  
save  
reopen, and the deleted items are no longer seen  
node-red-start  
the deleted items are added at the end of the context.json file  
in the flows there is no code which manipulates the deleted items

What is going on? How to solve this?

thx for any suggestions

---

<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: [11 February 2025 10:33 UTC](https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310/2 "2025-02-11T10:33:10Z")

</div>

You can in a change node  
`delete flow.path `  
And in a function node  
`flow.set(path, undefined)`

---

<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: [11 February 2025 10:51 UTC](https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310/3 "2025-02-11T10:51:54Z")

</div>

> [@wwyyrrmm](#):
>
> in the flows there is no code which manipulates the deleted items

I suspect you may be mistaken. If you delete the data from the file then something must be writing it back.

---

<div class="post-metadata">

### Author: ![wwyyrrmm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wwyyrrmm/32/75728_2.png) [@wwyyrrmm](https://discourse.nodered.org/u/wwyyrrmm)
#### Post date: [11 February 2025 12:30 UTC](https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310/4 "2025-02-11T12:30:32Z")

</div>

it must have to do with copy / Backup from another file or with memory flush ?

---

<div class="post-metadata">

### Author: ![wwyyrrmm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wwyyrrmm/32/75728_2.png) [@wwyyrrmm](https://discourse.nodered.org/u/wwyyrrmm)
#### Post date: [11 February 2025 12:31 UTC](https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310/5 "2025-02-11T12:31:54Z")

</div>

yes, but that are too much entries (hundreds)

---

<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: [11 February 2025 12:38 UTC](https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310/6 "2025-02-11T12:38:09Z")

</div>

> [@wwyyrrmm](#):
>
> to set it to undefined will not erase the enty, it is only set to undefined

Then use delete

```auto
let foo = flow.get("bar");
delete foo.path;
flow.set("bar", foo);

```

> [@wwyyrrmm](#):
>
> yes, but that are too much entries (hundreds)

Maybe you should rethink how you store the globals to make things less dirty.

---

<div class="post-metadata">

### Author: ![wwyyrrmm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wwyyrrmm/32/75728_2.png) [@wwyyrrmm](https://discourse.nodered.org/u/wwyyrrmm)
#### Post date: [11 February 2025 13:24 UTC](https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310/7 "2025-02-11T13:24:20Z")

</div>

```auto
var cDevices = ["81", "82", "83", "84", "85", "86", "87", "88", "89"];
var cTypes=["RAlarmT","RAlarmF","RAlarmQ"];

let dLen = cDevices.length;
let tLen = cTypes.length;

for (var i = 0; i < dLen; i++) {
    var cTemp1=cDevices[i].replace(/\s/g, '_');

    for (var ix = 0; ix < tLen; ix++) {
         var cTemp2=cTypes[ix];
         var cToDelete=cTemp1+cTemp2;
         node.warn(cToDelete);
         global.set(cToDelete,undefined,"file");
    }
}

```

and so on with other Kombinations not nice, but a very dirty solution

---

<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: [25 February 2025 13:25 UTC](https://discourse.nodered.org/t/problems-deleting-items-in-global-context/95310/8 "2025-02-25T13:25:06Z")

</div>

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