Efficient way to delete multiple entries from local storage

Efficient way to delete multiple entries from local storage

  

Hello,

do any of you know an efficient way to delete multiple entries from local storage in OutSystems mobile.


I don't want to delete all the entries.

The foreach method, where you iterate through a list and delete one at a time, is extremely slow.

Therefore, I'm hoping that there is a way to delete all entries in an aggregate?

Hi Guðrún,

Welcome to the forum, and congrats on being the user with the most awesome characters in their name :).

I'm afraid the foreach method is the only way. There's no way to bulk delete (like with a SQL Statement).

Kilian Hekhuis wrote:

Hi Guðrún,

Welcome to the forum, and congrats on being the user with the most awesome characters in their name :).

I'm afraid the foreach method is the only way. There's no way to bulk delete (like with a SQL Statement).


Thanks for the quick reply,

could you recommend a way in which I can estimate if the deleteAll or the forEach method is more time efficient for my case?

Hi Guðrún,

I totally forgot about the DeleteAll on Mobile, appologies. I would think that the DeleteAll would be much faster.

You have DeleteAll in Local Storage Entity...

Just use that....

It's more efficient with less roundtrip between server and database.

Harlin,

DeleteAll is only available on Mobile, and therefore there's no server, and no roundtrips. It's all local on the device.

Yes, I think I will use DeleteAll.

My original plan was to just get a few entries (the ones that were updated since my last sync) from my webservice  and update them in local storage by deleting those specific entries and creating new ones.

It was taking so much time to get thousands of entries from the webservice each time and deleting them all in local storage, just to create most of them again in identical form.

Solution

Well, if you're talking about syncing, one of the patterns is indeed DeleteAll + CreateAll, but obviously this is for limited amounts of data only. If there are updated entries, I wouldn't delete + create them, but update them (using the UpdateEntity Action). It basically all depends on your use case, but I'm confident you will manage to find the most efficient way.

Solution