cancel
Showing results for 
Search instead for 
Did you mean: 

Can i delete data from ODataOfflineStore only from the device?

Former Member
0 Kudos
265

In my app the user must fill in a form and submit it. The process is to insert data via store.executeCreateEntity(…) and then call store.flushQueuedRequests() in order to send the data to the backend. After flushing the user has the data both in the device and the backend.

How can I delete data from the device only? If I call store.executeDeleteEntity(…) all deleted data wil be also deleted from the backend too in the next store.flushQueuedRequests().

Also, store.closeStore() seems not to delete data but only destroy the object from the memory.

I only want to delete data from a store in the device. Is it possible?

Former Member
0 Kudos

can i open a store then execute store.executeDeleteEntity(…) and close the store without flushing? would it work?

View Entire Topic
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert

Hello spanaretos ,

Please understand offline flow ,

Initially, when you make a call to create OfflineStore, you would have 2 UDBs on your local device for that particular app , one is local copy of data that you requested to be available in offline and second one is request queue udb

All the local changes are queued to that second udb

FLUSH is performed on that second udb (request queue), it means that all local changes/requests are being send to back-end. Once this is successful (received by backend), the request is deleted from the queue, the change is made to backend.

When you perform a REFRESH call next time, new version of object is sent to offline store.

Regards

JK

Former Member
0 Kudos

1) what if someone changes a record to the back end and i want that new version of it? Does refresh send the updated record?

2) What happens if someone deletes a record in the backend? Is it deleted from local after next refresh?

3) Also if a store contains too many data, doesn't is full the available memory at some time? Think about a case where I have a defining request with ?$filter=FIELD eq 'nonsense', in this case i do not download anything (because of the value of $filter) but i can create new ODataEntities just to post my data to the backend. So, I end up with my local store getting full (since i have to save locally first and then flush).. Can i delete these local data?

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos
spanaretos

1) Yes, you need to call REFRESH in order to have updated record

2) If someone deletes a record in backend, so in order to have it synced with local data(store), yes, you need to call REFRESH

3) but i can create new ODataEntities just to post my data to the backend.

can you share more details on this?

Regards,

JK

Former Member
0 Kudos

3) I want users to fill in a questionnaire every week and submit it but i don't need questionnaires' data in the local database after the submission (they don't have to read them again). Could i delete this data only from the device so as not to take up any space?

Of course i want the data to remain in the backend because the admin should be able to read them and make reports etc.

Also, i can set a filter in the defining request that is never true, so each time the user opens the app and the offline store is opened this data will not be downloaded again in the device.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
I want users to fill in a questionnaire every week and submit it but i 
don't need questionnaires' data in the local database after the 
submission (they don't have to read them again). Could i delete this 
data only from the device so as not to take up any space?

when user submit filed questionnaire, i am assuming its not submitting to backend at the moment, you need to FLUSH explicitly right? If this happens so, this request/local changes will be pushed to backend , will not be shown in device unless you explicitly call REFRESH

Former Member
0 Kudos

as described in the flush method in sap docs i understand the flow as:

1. record is saved in local store

2. record is added into the queue

3. when flush is called the record is submitted to the remote backend and is deleted from the queue, but it remains in the local store. This causes local data of the application to go up to very large numbers.

There should be something like an annotation that tells the store "do not keep in store just add it in the queue to be submitted" or "delete after successful flush"