Online Data
Your Online datastore, should be quarriable.
Last updated
Your Online datastore, should be quarriable.
Last updated
Now, here we need to keep a copy of all data, user will use this to sync data between devices.
Here we do not have to do any thing, we will keep each document stored and query as we need.
Devices: Keep track of all installationId
and lastUsedAt
, can also store extra information such device name, version etc.
userId
: Firebase Auth Id of User
installationId
: will keep track of all the installations done by the user
lastUsedAt
: should be set to last uploaded documents timestamp, will be used to get devices that uploaded after my devices has downloaded last time. we will exclude my device id from this list so I won't download documents uploaded by me (Because.. Duh.. this device already has those).
User: Your user record, we will store user's information.
Notes: You data that needed to be synced across devices. It will inherently contain all the fields from local database plus, createdOn
updatedOn
and updatedBy
fields. We also need to add some extra fields here for syncing uploadedAt
Firebase has another complication which can lead to scalability issues.
So, while creating these data, make sure you can provide access to data based on Role(Firebase Tokens).
If you to share data between user's (data created by one user should be accessible to another user), then do not nest your data, i.e. do not put Post
inside User
Collection, create User
and Notes
as 2 separate root level collections.