How to update Local Storage array

If we have an array of objects in local storage and we want to change a specific field of an object at a given index how can we do this. In my case I have an array named “bookings” and in this array there are multiple json objects, I want to change the some fields of json object like starttime of booking which is at index=pointer, pointer is a variable pointing the booking on which we want to make changes. I have tried this one local1.data.bookings[local1.data.pointer].set(‘starttime’,var1.datetime) but it doesn’t worked.

1 Like

@ben
Sir any suggestions for this.

If I interpret the question properly, I read that you want to change a value inside of a keyed array.

If that is the case, then this may help.

We are not dealing with array component instead we are using local storage array like this


In this array there are multiple json objects which we are fetching via API call. image
We want to update the fields in json object like bookings[0].Created Date=10th Nov etc.

We are using pointer variable for index of array and using this line of code "local1.data.bookings[local1.data.pointer].set(‘starttime’,var1.datetime) " to set local storage value but it’s not working.

OK, I think I get it now. I think that you should be using Data Store for this. I am not sure where you are getting the data from, this could be a JSON file, from form inputs or from a database. It does not matter. In either case you can populate the Data Store with the data retrieved and use the methods for the Data Store to manipulate the data.

Have a look at the following to get the idea.

Thanks for your time Sir!
This is the json which we are getting from bubble database.


It contains multiple objects in which there are multiple arrays. What we want is to update each value of array and other fields of object. We have tried datastore as well but unable to perform update delete operations correctly, due to nested data we facing difficulty in performing operations this data.

I see the problem. What I see is a generated document. There must be a program that retrieves the data from a data source to then present it in this format. I think that you should be working from the data source instead of working from the report.

Yes I have this problem as well. Local storage feature allows us to create object and array (including keyed array?) but there’s no option to insert or update them. Only variable can be inserted and updated.

1 Like