JetpackDao

interface JetpackDao

DAO for handling JetpackEntity operations.

Functions

Link copied to clipboard
abstract suspend fun deleteJetpackPermanently(id: String)

Permanently deletes a jetpack from the database.

Link copied to clipboard
abstract fun getJetpack(id: String): Flow<JetpackEntity>

Retrieves a specific jetpack by its ID.

Link copied to clipboard
abstract fun getJetpacks(userId: String): Flow<List<JetpackEntity>>

Retrieves a list of jetpacks for a specific user that are not marked as deleted, ordered by the last updated timestamp in descending order.

Link copied to clipboard
abstract suspend fun getLatestUpdateTimestamp(userId: String): Long?

Gets the most recent lastUpdated timestamp for a specific user's jetpacks. This can be used as a reference point for fetching only newer items from remote.

Link copied to clipboard
abstract suspend fun getUnsyncedJetpacks(userId: String): List<JetpackEntity>

Retrieves a list of jetpacks for a specific user that need to be synced. A jetpack needs to be synced if it was updated after the last sync or if it is marked as needing sync.

Link copied to clipboard
abstract suspend fun insertJetpack(jetpackEntity: JetpackEntity)

Inserts a new jetpack into the database. If a jetpack with the same ID already exists, it will be replaced.

Link copied to clipboard
abstract suspend fun markAsSynced(id: String, timestamp: Long = System.currentTimeMillis())

Marks a jetpack as synced by setting the needsSync flag to 0, the syncAction to 'NONE', and updating the lastSynced timestamp.

Link copied to clipboard
abstract suspend fun markJetpackAsDeleted(id: String)

Marks a jetpack as deleted by setting the deleted flag to 1 and the needsSync flag to 1. Also sets the syncAction to 'DELETE'.

Link copied to clipboard
abstract suspend fun updateJetpack(jetpackEntity: JetpackEntity)

Updates an existing jetpack in the database.

Link copied to clipboard
abstract suspend fun upsertJetpack(jetpackEntity: JetpackEntity)

Inserts or updates a jetpack in the database. If a jetpack with the same ID already exists, it will be updated; otherwise, a new entry will be created.

Link copied to clipboard
abstract suspend fun upsertJetpacks(remoteJetpacks: List<JetpackEntity>)

Upserts (insert or update) jetpacks from a remote source. If a jetpack already exists locally (matching ID), it will be updated with the remote version. If it doesn't exist locally, a new entry will be created.