How to Export flows as a message

Hi,
As far as I know Node Red editor saves the current flow(the flow you see when you open the editor) in flows.json file inside C/[username]/.node-red folder by default.

Can I force it to read and display the flow from MongoDB or a different file instead of flows.json when it started?

Alternatively, is there a way to get flows.json(the same json you get when you click export) with a node and send it as a msg.payload?

Yes, with a storage driver. e.g: GitHub - adibenmati/node-red-mongo-storage-plugin: Node Red Mongo Storage Plugin

Since it is a file, on the file system, yes: file in -> JSON node -> wherever

Thanks for all your answers so far.

So if I understood correctly, when I add an entry (the flow i want to be displayed) to local mongo, that flow will be displayed when I started Node Red. Instead of the latest one I deployed, right?

I didn't understand what to do with the information in the first link. I'm currently running node red on base directory with "node red.js" command. Should I put the node-red-app provided in the same directory and run Node Red with the command "node node-red-app.js?" after setting up a local Mongo DB?

What parts don't you understand? The link provides all information necessary to get up and running with that plugin.

Can I ask?

Why do you want to save the flows in a mongo database? What is the goal?

From what I understand I need to define my own red.js which I use to run Node Red Editor. I used the one provided in the github link above. And replaced Mongo-URL with my own DB's. Now, before running Node-RED it connects to my db but how do I save the flows file into and load from my MongoDB collection? It still uses the flows file in user directory.

You can run node-red with commandline options - which port and which flows file.

You cannot use node-red to read your mongodb get all the flows and run it as such.
You could get specific flow(s) from mongo and using the node-red api to apply the flow.

I'm currently running node red on base directory with "node red.js"

Please don't.
Just use node-red, node-red [options] or node-red-start (depending how you installed it)

Why? Just run node-red.

Then you are not doing it right.

As the instructions say.

Firstly, require the module:

npm install --save node-red-mongo-storage-plugin

Then, in your settings, add:

After adding your settings, start node-red.


one more time

If you answer this :point_up: , we may have alternative solutions or best practices!

A storage plugin such as the mongo one, saves and loads flows directly from a different source. You might be saying the same thing but i read your statement as "it cannot be done"

For example, FlowForge uses this for saving all users flows from all the Node-RED instances into a SQLITE or PostgreSQL DB out of the box (depending on your choices)

Ah ok i was not aware of that one, nice!

1 Like

I want multiple users to work on the same flow, while running different node-red instances simultaneously.

Currently I am running 2 Node-Red instances in different ports locally. When first started, both of them displays the flow I stored in MongoDB. Let's assume there is a flow in json format with 3 nodes in MongoDB. If I remove one of the nodes in instance A via the editor, MongoDB overwrites flows.json collection to have 2 nodes. But, when I refresh my page in instance B, there are still 3 nodes instead of 2. I want the changes I've made in instance A to be reflected on instance B.

This is something you would have to do yourself. Alternatively, you can already do this in FlowForge using devices and / or the pipelines features.

Thank you Steve. You've been really helpfull.

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