Discard stored context with ease

#1

It may happen that if you are experimenting with you flows and you use context storage you may find at one point that you have a lot of scrap data stored and you may want to just wipe all. With persistable context with caching enabled it is kind of pain.
Here's a little helper for you.

[{"id":"45862c08.b69d64","type":"inject","z":"64513f88.6f389","name":"GLOBAL CONTEXT - DISCARD ALL","topic":"","payload":"DISCARD","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":120,"wires":[["b41ba9df.53b0a8"]]},{"id":"b41ba9df.53b0a8","type":"function","z":"64513f88.6f389","name":"DISCARD","func":"var keys = global.keys();\nfor(var i=0;i<keys.length;i++){\n global.set(keys[i]);\n}\nnode.warn(\"global context cleared!\");","outputs":1,"noerr":0,"x":440,"y":120,"wires":[[]]}]

It wipes all so handle with care :slight_smile:

4 Likes

#2

Hi.
Does this works for flow context?
How would be?
Thanks.

0 Likes

#3

Have you tried to replace global with flow in function node?

0 Likes