Frontend database

Hello everyone,

I’m creating an invoicing app and the biggest concern I have all the time is that since I have an invoice page and then inside invoice line items is that to populate the RG I always have to touch the database.

I was wondering if I’m 2022 someone has achieved something like having a frontend database that on a save button in the page you can save the list of inline items.

Keep in mind that each line item needs to have each inputs such as price, quantity, taxes, …

Thanks a lot to all!

You could do this by using a text string and putting different things in the text separated by a unique character

For instance you could store a product UUID, price, quantity and user UUID in a single text

For instance it would look like
Abcdefg;$5;10;abcdef :split by ;

From that your recieve a list of texts
Item 1 = abcdefg (product UUID)
Item 2 = price ($5 but you would probably store it as just a 5 then do a :convert to number)
Item 3 = 10 (quantity, again for a convert to number)
Item 4 = abcdef (user UUID)

Lots of people like to do this in JsON format and convert it which is another option

1 Like

Hey @chad

But each line item has different inputs such as the price, quantity, …

I know how to generate a custom state as a list but how do you put the fields in a list and after the save the button how do you create the each item in the database as a new record?

Thanks a lot @chad

Set state “line item” (text) = Arbitrary text (Input names value;input qty’s value;input price)

Create new thing
Name = line item :split by ; item #1
Price = line item :split by ; item #3
Qty = line item :split by ; item #2

The symbol ; is what you split by


If you have multiple line items you can make the state a list of texts

1 Like

Hey @chad

I’ve been trying to understand it all day but still no clue of I can do that.

Do you have an example?

Thanks a lot for your help :slight_smile:

I don’t know if I follow @chad

My goal is:

  1. On page load, having 1 line item created on the frontend that the user can modify its inputs.
  2. Let the user create new line items with its values.

On the save button:

  1. Create a new invoice record in the database.
  2. Save the line items, each line item as new invoice line item record in the database.
  3. Attach the new line items to the invoice.

Does it make sense?

Hope it does :grinning:.

Thanks a lot.

Have a look through this guys videos. Really helped me with saving data at front end.


A more concise way to do this is just to write javascript functions and return variables corresponding to what you want to save. If the list of things is too large, you’ll end up with big objects though.

1 Like

Hey @simonperks81

That looks good, but I’ve the add line item outside the RG and the line item inputs inside the RG.

I mean in the RG I need to have the line items and the user needs to modify the line item’s inputs that are inside the RG not just like in the video that it has the inputs outside the RG.

Will this work with the inputs inside the line items?

Wow! Now I’m lost, hehe. List of items could be big. But it’s line items so …

Hi @ryanck,

I’m just wondering why that’s a concern. What’s wrong with “touching the database”? I personally haven’t found performance to be an issue in similar scenarios.


i agree here-- a list of texts and numbers shouldn’t be causing performance issues. How is your database structured? How are you loading things into the repeating group?

JS Objects are the closest thing to “frontend database” here, but I don’t think you need them.

1 Like

Hey @sudsy and @dannyliu

I don’t have an issue performance wise but with the database I need to keep for each line item two record, one as valid and another one as a draft one.

So that I’m not saving the valid ones all the time. And then you can see how difficult it is to manage loads of draft items and valid ones.

That’s the reason, so I can keep things simple.

Do you know if it would be possible to do as:

Thanks a lot for taking the time to help! Highly appreciated.

I see. I’m certainly a big fan of simplicity, but I’m a bit unclear as to why two separate records are needed for each line item. Could a single record with a Status field be used - i.e. just change that field’s value from “draft” to “final” when the invoice is saved/finalized?

Hey @sudsy

I wish it could like that but no.

Let’s think that a user creates a new invoice but then after, he wants to edit the invoice. If he modifies the values of the line items he is actually touching the status yes so even if he does not save the invoice, he is actually modifying the line items.

Because of this what I do is whenever a user edits an invoice, I duplicate the line items and set them as draft so if the user touches those line items and then leave without saving, the valid lines won’t be affected.

Hope it does make sense.

Hope you have some idea.

Thanks a ton!

may I ask, what is wrong with touching the database?
it so happens that this is the most efficient way to do it.

So the duplicate line items are in case the user wants to cancel/revert the edits?

1 Like

Yes the duplicated line items are in case a user wants to edit the invoice so he does not edit the validated ones.

isn’t there a 10x easier way to do this?

  1. load the list of invoices onto the page as a custom state.
  2. Create a form within a RG that shows the invoice, with the initial value coming from the custom state.
  3. When the user modifies the form, they must click “save”-- no auto binding. Since every RG’s cell contains one invoice, you can just make changes to that single invoice when the user finishes editing a draft.

you can also opt to display the information as a popup as well, and send a different RG cell’s invoice into the popup.

This way, you are never making changes to any list, and there shouldn’t be a load time.