Offline Data
Data you collect offline, has to be shared with other devices
1. Attach tracker to each object
Each object that has be synced, must contain following properties:
createdOn
: Should be immutable, first time the object is created.updatedOn
: Should be mutable, should be set to epoch time every time this data is updated.updatedBy
: Should be mutable, this is your device's installation Id, try to store it inSharedPreferences
orUserDefaults
serverId
: id generated by server, should be used to update document while downloading from Online ServerisDirty
: Should be mutable, this is set totrue
whenever data is updated locally.
If you are implementing sync for an existing data set, make sure you iterate through all of your data and mark them dirty
2. Create data-sync tracker
There is also another table, it will keep track of your downloaded data. You record timestamp of last downloaded object for each table you want to sync.
DownloadTracker
table is not synced with Firestore, instead we will later use it to sync differential after we restore our DB file from AWS S3.
Last updated