pullJetpacks
Pulls (downloads) a list of Jetpack items that have been updated since the last sync.
This method implements incremental sync by querying only items that changed after lastSynced. This minimizes network usage and improves sync performance.
Query Logic
Firestore.collection("dev.atick.jetpack/jetpacks/{userId}")
.where("lastUpdated", ">", lastSynced)
.get()Soft Deletes
Deleted items (where deleted = true) are included in the results. This allows the local database to properly handle deletions that occurred on other devices.
Performance
Returns only changed items (not the entire dataset)
Firestore indexes should be configured for the
lastUpdatedfieldResults are ordered by
lastUpdatedascending
Example
suspend fun syncPull() {
val userId = getCurrentUserId()
val lastSync = preferences.getLastSyncTimestamp()
val updates = firebaseDataSource.pullJetpacks(userId, lastSync)
updates.forEach { remote ->
localDataSource.upsertJetpack(remote.toEntity())
}
preferences.setLastSyncTimestamp(System.currentTimeMillis())
}Return
A list of FirebaseJetpack objects that have been updated since lastSynced. Returns an empty list if no updates are available.
Parameters
The unique identifier of the user (Firebase Auth UID). Only items belonging to this user are returned.
The timestamp (milliseconds) of the last successful sync. Items with lastUpdated > lastSynced are returned. Use 0L for the initial sync to fetch all items.
Throws
if the query fails
if network is unavailable