See if this helps you. It's something I wrote awhile ago but still hold up.
and the here is a link to the documentation:
https://nodered.org/docs/api/context/
and also read this:
https://nodered.org/docs/api/context/store/localfilesystem
and pay attention to the options!!!
(hint hint)