alyssaxuu / flowy

The minimal javascript library to create flowcharts ✨

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Best practice to store the created diagram

ThomasSquall opened this issue · comments

Hello everyone, I'm implementing flowy in an application with Laravel/MySQL backend.
I'm using the flowy.output() function to extract the diagram and send it to the backend through ajax in charge of storing the diagram for future updates.

The issue here is that storing it in the DB easily results in "SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'html' at row 1" (roughly with 8/10 nodes).

I was thinking to store the diagram in a file but first I wanted to ask you if you have a better approach.

Thanks all!

If you want to store the long nodes in the SQL database I prefer to store it in JSON format.

I used in my case 3800 Nodes converted into the JSON string and stored in the SQL. If you really want to store in the file format indeed can but security and weight of the node is matters.

Hi @ravikoppula thanks for your answer.
So if I understand properly, you didn't store the actual output but you stored a sort of "tree" of the flow into a JSON and then, when reloading, you construct the html you need from the JSON tree and then input it to the flowy. Is that correct?

I was hoping for a quicker solution (like saving the flowy.output() and then importing it with flowy.input(output)) to implement this library into my project as I am not a true lover of Frontend but if this is the best option that I have surely I'll do it.

Thanks again for your help!

@ThomasSquall I believe what @ravikoppula means is to create a MySQL/Postgres column of the JSON data type. This way you can just store the output of flowy.output() (which is a JSON object) and load with flowy.import(output) as you intended.