Storing custom state list to Database

Is it possible to store custom list to Database.

Example:
I have a list of dishes that are stored in my database, i want to select several dishes and then send them to the database as a list.

Could custom state lists do this?

Hi there, @dalatcafebestilling… yes, you can take a list that is being stored in a custom state and store that list in a list field in a data type.

When you create the custom state, make sure its type matches that of the items that will be stored in it as well as the field in which the custom state list will eventually be stored in the database, and make sure the custom state is a list (obviously). Then, when a dish is selected (whatever that means in your app), update the custom state list to its current value plus the item that was just selected. Finally, when you want to store the custom state list in a field in the database, use the add list or set list operator, and you should be good to go.

Hope this helps.

Best…
Mike

thank’s mike for the help, it works now!

1 Like

Just a quick question how can i select the same item several times?
And it gets stored in a list?

Bubble doesn’t allow duplicate items in lists. Why do you need to have the same item stored multiple times?

I need it if one person wants to order the same dish twice, i would like to see it in data

how can i solve this?

Hard to say without knowing exactly what your app does and how it does it. You might want a quantity field to denote the number of times a dish was ordered.

I need it if one person wants to order the same dish twice, i would like to see it in data

Create something like a line_item or order_item and store the quantity on there.