Tim Dietrich

Custom Software Developer

Home Services Portfolio Blog About Contact Newsletter

EasySync: Thoughts On Handling Deletions

During the development of EasySync, I spent a lot ot time thinking about, and chatting with other developers about, how to handle deletions. Deletions make the sync process, which is already rather complicated, even more complicated.

Here are some notes that I squirreled away in Evernote about how I think deletions could be handled.

Deletions Made on the Mobile Device:

  • In the mobile database, add a "flagged for deletion" field that indicates that a record has been flagged for deletion.
  • During a sync, that "flagged for deletion" field would get pushed to the server just like any other field in the payload.
  • On the server side, after a push payload has been received, find the flagged records, and evaluate each one to see if there is a conflict that should prevent the deletion. If not, delete the record on the server side.
  • On the mobile side, after a successful push, delete the flagged records. If the record is retained by the server, it should eventually get pulled back down during a future sync.

Deletions Made on the Server:

  • After a sync, do a "sync check" with the server.
  • The mobile database would send a payload consisting of the ES_Record_UUIDs for all of the records stored locally.
  • The server would return a list of the ES_Record_UUIDs that it doesn't have.
  • The mobile database would then delete those records.
  • This would need to take into account records that are on the mobile side that are flagged as "Do Not Sync."

I'd love to hear your thoughts on this. Leave a comment below and let's get a conversation started.