How to delete record from server DB in offline Sync Read-Write pattern


I have used read-write sync pattern for offline, having some issue with it;

1- when  offline & delete record it gets deleted, but when came online again it is there as of it is on server DB.

2- when try to delete when online, it is not deleting.

My Delete Action:


When you are online you are deleting from server and then get all from local. When you delete from server it doesn't automatically delete from local unless you synchronize. And when you delete local you need to synchronize to server when you come online.




What Marcelo said is correct. You have to mark your local records as deleted without deleting them locally when offline (you'll have to adjust your aggregates with to retrieve records not marked as deleted) so when going back online you'll be able to ask for delete them on server.

And when you are having your application online be sure you are also deleting the local version if record exists.


Hi assif_tiger,

Complementing Fabien's spot-on answer, you have quite detailed explanation of a simple read-write sync pattern here, it explains how to implement synchronisation when you can change data while offline, and what changes you need to make in your data-model and logic in order to support it.