Node properties stored in external json file

I have created a flow which reads the data from mongo db and dump them into csv file. I want to configure any of node's property which resides in the external json. So what I would like to do is read the properties from external json file and set those to nodes in the editor. so how can we do stuff like this?

What does dumping mongodb data to a CSV file have to do with loading JSON?

Do you mean at design time or at runtime. You cannot load a file in the editor and setup node properties.

It is however possible to load JSON into env vars (by requireing it in your settings.js file) and using {ENVVAR} in some of the nodes properties

It all depends on what properties you wish to adjust.

hii steve, lets consider a scenario where each user is using mongo db in node red and they have different url and port number for mongodb. so I want to provide a json file where I can mention url and port number, and I will read those properties in node red editor and set those to mongo db node. This is what I want?

Would these users have their own node-red installation or be sharing one node-red?

Also, are these users actually modifying node-red flows in the editor or using a dashboard provided by node-red?

yes all these users have their node red installations. I will just provide them external configuration file which has those properties.

actually they will run node red from terminal as node red is embedded in node js

So if these users are editing their own node-red flows, then just let them enter the details in the mongodb config node UI

You can use ENV VARS for server, username, password etc. So these can be entered in the terminal before launching node-red or added to the users env vars for that user.

Lastly, as I said before, you can require a JSON file in settings.js and create env vars in the settings.

not sure what you mean by this
node-red runs on node-js

This means that, when we start the node js server it automatically starts node red.
You can see following url:
Embedding into an existing app : Node-RED.

sorry I am new to node red, can I get one example how we can use env variable inside settings.js and use it in node red.

See this: How to set env variable - #5 by knolleary

From the docs

Any node property can be set with an environment variable by setting its value to a string of the form ${ENV_VAR} . When the runtime loads the flows, it will substitute the value of that environment variable before passing it to the node.

This only works if it replaces the entire property - it cannot be used to substitute just part of the value. For example, it is not possible to use CLIENT-${HOST} .


Thank you for the helping me out.. :slightly_smiling_face:

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