# Is saving flows (per tab) in database any easier in node-red 1.0?

**URL:** <https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004>\
**Category:** General\
**Created:** [1 September 2019 16:15 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004 "2019-09-01T16:15:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![darrencruse](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darrencruse/32/9568_2.png) [@darrencruse](https://discourse.nodered.org/u/darrencruse)\
**Post date:** [1 September 2019 16:15 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004/1 "2019-09-01T16:15:53Z")

</div>

I've been playing with node-red for awhile now as a hobby but dreaming I could use it on my day job where we create RESTful json apis using node.js.

After looking pretty hard I've **not found good solutions to** :

a. **All the flows in one giant json file** (we will have hundreds of flows created by different teams where we have to restrict access who can access and edit which flows - having all that in one single giant json file is a non-starter)

b. **Storing the flows in a database instead of the file system** (I've studied the storage api and tried out e.g. node-red-flows-mongo but am I right the _save_ part of the storage api assumes you are saving all the flows at once i.e. "a" above).

I know a lot has been happening re the editor/run-time split and the 1.0 beta release - is there anything with this work that would provide hooks I could plug-in to customize the above?

e.g. I wish the editor and storage api had something where the user would save their changes to the flow on a single tab and POST the json for just that flow to be saved.

The closest I see to that is saveLibraryEntry but I confess I've not tried to use the library features at all... is it conceivable I could save each of my tabs flows as individual "library entries" as database records, and then have my "getFlows" query those to dynamically aggregate back together the giant all-flows json?

Or can anybody think of anything better?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 September 2019 16:24 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004/2 "2019-09-01T16:24:16Z")

</div>

There is nothing new in this area in 1.0. the runtime/editor split work was in 0.20 and there hasn't been any new changes to that since.

The storage API gives you everything you need to save things however you want. Yes it's a single call to save your flows, but you can split up the json you given and store the different parts wherever and however you want.

There are no plans to change the editor to only deploy the current tab.

After 1.0 is done, there is scope to think more about how we can better accommodate multiple users trying edit the same set of flows at the same time. Just depends whether anyone interested in that is interested enough to help make it happen. Otherwise it sits on the backlog along with everything else and waits it's turn.

---

<div class="post-metadata">

**Author:** ![darrencruse](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darrencruse/32/9568_2.png) [@darrencruse](https://discourse.nodered.org/u/darrencruse)\
**Post date:** [1 September 2019 16:33 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004/3 "2019-09-01T16:33:49Z")

</div>

Thanks (and node-red is awesome btw my frustration is that it's **soooo close** to being exactly what my work project needs but with little things like the above being show stoppers).

I did think about splitting the big json up behind the saveFlows call - but I'd have no way of knowing what really changed in the big json right so I'd have no option but to split it up and rewrite _everything_ on _every_ save.

Or is there some meta-data with each of the tabs/flows e.g. modified by, modified datetime something like that? Or are there ways I could incorporate such "meta data" myself?

I should have said btw I _am_ "interested enough to help make it happen" and I'm experienced with node.js and browser javascript it's just I'm new to understanding the node-red design (I've looked a bit at the node-red code but there's quite a bit to it!! 🙂)

---

<div class="post-metadata">

**Author:** ![abhutada](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@abhutada](https://discourse.nodered.org/u/abhutada)\
**Post date:** [23 June 2021 13:15 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004/5 "2021-06-23T13:15:13Z")

</div>

I have the exact same requirement too.  
I have worked for a long time in operational automation for large enterprises (and small ones too).  
Current way of storing ALL flows in a single JSON is possibly the biggest holdback I have before I can push the awesome node-red for enterprise ready use.  
I am also extremely interested in helping to make this happen.  
Need some guidance on design of where the flows are getting stored and loaded from (where the json is actually read and written to) and how can we make it render via a DB query.  
I already have a UI to manage Role based access to edit, execute, control a list of flows that are visible, executable, approval workflow for optional maker-checker functionality (where human in the loop is mandatory for compliance reasons).

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [23 June 2021 13:20 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004/6 "2021-06-23T13:20:48Z")

</div>

Hi @abhutada

as I mentioned in my previous reply, you can use the Storage API to create a custom storage plugin for the flows.

[https://nodered.org/docs/api/storage/](https://nodered.org/docs/api/storage/)

---

<div class="post-metadata">

**Author:** ![tve](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tve/32/59475_2.png) [@tve](https://discourse.nodered.org/u/tve)\
**Post date:** [23 June 2021 15:12 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004/7 "2021-06-23T15:12:49Z")

</div>

It seems to me that the use-cases in this thread are calling for multiple Node-RED instances, not so much for splitting up the flows. The NR process is not that heavy, running one per user or per application domain (whatever that ends up being) seems like the right solution.

There are access control issues mentioned in this thread that cannot be solved either, so that points to multiple instances. Even if all this was solved, the node runtime is still single threaded, so one slow function node holds everything else up, plus, I assume that in these use-cases you'd be running on a server with a large number of cores and then you'll be asking why does node only use one.

In other words, I do not believe " it's soooo close" is accurate in the sense that that statement was meant, there would be a ton of work necessary. But I believe it's actually already there: just run multiple instances.

---

<div class="post-metadata">

**Author:** ![abhutada](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@abhutada](https://discourse.nodered.org/u/abhutada)\
**Post date:** [21 July 2021 14:39 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004/8 "2021-07-21T14:39:51Z")

</div>

I tried the following 2 options.

> **[node-red-contrib-multi-flows-storage](https://www.npmjs.com/package/node-red-contrib-multi-flows-storage)**
>
> A Node-RED storage plugin that organize flows and subflows in folders as YAML or JSON for readability

> **[node-red-contrib-storagemodule-postgres](https://www.npmjs.com/package/node-red-contrib-storagemodule-postgres)**
>
> A module to provide Node-RED persistence using a postgres database instead of the default filesystem

The YAML solution (multi-flows) seems to be working closer to what I want - saving each flow in a separate YAML file.

However when using the postgres option, could not get too far:

- everything still stored in DB just as a single row
- cannot find reference to the tab created in the actual DB data  
Not sure if mongodb plugin works differently.  
[Saving flows into Database - #17 by knolleary](https://discourse.nodered.org/t/saving-flows-into-database/30549/17)

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [21 July 2021 14:45 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004/9 "2021-07-21T14:45:39Z")

</div>

What's passed to the storage API is just the same JSON object that is stored in the flat file when using the default storage plugin.

All the existing storage plugins are going to just store that object as that is what needs to be returned to Node-RED when it requests the flow to run.

If you have different requirements (e.g. to store the tabs separately) then it is going to be up to you to implement that by understanding the structure of the flows JSON object so you can break it up and rebuild it from the parts later.

---

<div class="post-metadata">

**Author:** ![abhutada](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@abhutada](https://discourse.nodered.org/u/abhutada)\
**Post date:** [22 July 2021 13:05 UTC](https://discourse.nodered.org/t/is-saving-flows-per-tab-in-database-any-easier-in-node-red-1-0/15004/10 "2021-07-22T13:05:16Z")

</div>

Agreed. However, the [node-red-contrib-multi-flows-storage](https://www.npmjs.com/package/node-red-contrib-multi-flows-storage) solution seems to be already splitting each flow into a separate JSON / YAML (based on what you choose).  
If each tab JSON is already available, is there a way to selectively Deploy only a specific tab (from its corresponding JSON) into another NR environment programmatically?
