JetpackDao

interface JetpackDao(source)

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 getSyncCursor(userId: String): Long?

Returns the maximum stored server write timestamp for this user, including deleted rows.

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())

Clears needsSync and syncAction by ID and updates lastSynced, without checking which version was uploaded. An edit made during upload can lose its pending flags.

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.