How to delete record from mobile local storage

How to delete record from mobile local storage

  

How to delete record from local storage using "mainproduct" as the where clause instead of "id"?

Solution

Filter out the record with the corresponding "mainproduct", and delete the (list of) record(s) that is returned by the query. You can use the ID that belongs to that record (or IDs that belong to the records). 

Solution

I would suggest to make a query for the mainproduct, and after the query delete the record by the Id.


I made the foreach, although it might depend on the number of records that you have

Hi Reynaldleo,

We can't delete from local storage because we don't have advance sql in mobile development. We can only delete via identifier i.e. ID.


You can follow below approach -

1) Use ListFilter in the client action and bind it with keranjang entity record list variable and in condition put GetKerangjangList.current.mainproduct <> mainproductname

2) Second step use listclear and bind it with GetKerangjangList, so it can clear all data in the current list.

3) Now use ListAppendAll, in List bind GetKerangjangList and in source bind ListFilter.FilteredList



It will solve your problem


Thanks,

Rajat Agrawal


Davide Periquito wrote:

I would suggest to make a query for the mainproduct, and after the query delete the record by the Id.


I made the foreach, although it might depend on the number of records that you have


Hi Davide,

I have one question here, if we have too many records then every time we need to make connection with the database to delete the records.

It also effort app performance.


Thanks,

Rajat Agrawal

thanks @sam @davide @rajat, this really helpful

Rejat Sorry I didn't understand you point. If you have too many records it will always impact your application.


Nevertheless, if possible you can try to trigger this action to run on the device background without impacting the user experience.


If the number of records to be deleted is greater as the number of records that will survive, maybe you first do a aggregate for all the records being not equal to the mainproductname, then do a deleteall which is very fast and an insert all with the outcome of the aggregate.. maybe that's fatser as a one by one delete ;-)


Regards,

Wim

That could be an option indeed I guess. I assumed reynaldleo did not have many records, since he was talking in singular to begin with. :)

Sam

The OP indeed sounded like he only needs to delete one record, later on someone else was talking about performance with high volume deletes so hence my 'solution' would be a thing to try ;-) but yours is much better for deleting only a few records. 

I have some experience with a big local table containing about 40k rows (yes it's big but they wanted to have an offline search possibility) and just reloading it each morning by just dump and reload is in my experience faster as check the diff row by row.