How to implement custom context store

Node_Red version 3.0.2

Hi all, I'm trying to implement a custom context store. I have read the documentation however I'm still unsure how to edit the settings.js file to create these stores, and I have the following question

  1. Can I create multiple context stores e.g. Store_1 (in memory), Store_2 (in memory), Store_3 (on disk)?
  2. How do I implement the "require" statement in the flows?

Can someone point me in the right direction so I can find an example that shows an example with multiple context stores implemented in the settings.js file?

Here is the example from the help files. I'm also unsure where to place the "required" statement in my flow.

The module property identifies the context store plugin to use. It can either be the name of built-in module (currently either memory or localfilesystem ), or it should be a module that has been loaded using require .

contextStorage: {
   default: {
   custom: {

Thank you for your help.

You need to edit settings.js find this section, and edit to look something like this -

contextStorage: {
   default: "Store_1",
   Store_1: { module: 'memory' },
   Store_2: { module: 'memory' },
   Store_3: { module: 'localfilesystem' }

This is not needed its configured in the settings.js file. Store_1 will be used by default. To use another in a function node you specify it after the name of the variable like this -

flow.get("detail", "Store_2")

In other nodes where supported you can pick from your list -

I would recommend including mem or file in the names, so you know which is which though.
Also not sure why you would want 2 memory stores ?

Thank you, very detailed and clear explanation. It is so wonderful to see this community support.

1 Like

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