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

1 Like

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

Hey guys,

I now it’s been 3 years ago but whoever is interested in manipulating Array fields inside DataStore, I finally did a small demo here…
Showcase: DataStore, Manipulating Array fields inside DataStore (Client_side) - Wappler General - Wappler Community

Forgive me if it is not relevant to your needs…

*** I would be very interested in learning how you handle this situation of Data Store array fields.

Hey @famousmag

Thanks for doing this article on arrays!

I’ve done a huge amount of work with DataStores for a booking form I created… they conceptually contain arrays but practically don’t…

So there is a conceptual structure of:

attendee[Z].question[Y].reply

But I couldn’t work out the array structure in Wappler so I created a datastore Responses with the fields (and possible values)

attendee: 1
question: 2
attendee_question: 1_2
reply: ‘bla bla’

It works a treat!

1 Like

Hey Antony,

So, you used an alternative temprary DataStore also?
(Loaded from the Main DataStore the “array” field into the temporary DataStore, updated them and send them baxk to the “array” field of your Main DataStore)

Yes! :tada:

1 Like