Arrays within data store

Is this a valid data store?

Seems like it should work, but I can’t insert the array field…categories

1 Like

yes I cant find how to this :slight_smile:

You can indeed store any data in the data store. We just haven’t found the best way for the UI to add the array options…

How would you like to do it?

Excellent question. Will have to ponder on that. In the meantime, is there a way to manually insert/remove items of an array like this?

I was thinking for two ways: either just a text entry that you bind with array variable or a grid with the array values?

Maybe my work around will help decide… I setup a second data store and include a variable in it that is the $id from the parent data store. basically replicating a db structure. This way I should be able to perform all needed actions.

1 Like

I guess grid with the array values will be good

1 Like

Data-store & Flows are real game-changers, I’m re-doing my app structure using these newbies! I’m also stuck in dealing with arrays in data store.

…the intermediary array variable option is too cumbersome, @mebeingken’s suggestion is great, but too much maintenance (maintaining joints between two datastores).

@George’s grid suggestion to handle arrays sounds like a great option… looking forward to this :slight_smile:

Also, here is another use case. The data store itself is an array (of objects). If I have a server connect returning array of objects, how do I assign it to the data store, instead of looping through the array of objects and inserting each record into the data store one by one (using the insert function)? Is there a set() function on data store, similar to what’s available on local & session storage components?

@mebeingken, this manual way should work, just in case you are still looking for it.

menu_item.insert({categories: array_of_objects})

where array_of_objects is an array variable (or) server-connect returned data

Well the problem with grid is that you have to enter all the records and I think you want a dynamic value there.

So just a simple input with picker should be enough