TacheDao.swift 30 lignes · 1199 octets
import Foundation

/// Port of the Room `TacheDao`.
protocol TacheDao {
    /// INSERT OR REPLACE INTO taches; returns the row id.
    @discardableResult
    func upsert(_ entity: TacheEntity) async throws -> Int64

    /// SELECT * FROM taches WHERE serverId = :serverId
    func getByServerId(_ serverId: String) async throws -> TacheEntity?

    /// SELECT * FROM taches WHERE localId = :localId
    func getByLocalId(_ localId: Int64) async throws -> TacheEntity?

    /// DELETE FROM taches WHERE serverId = :serverId
    func deleteByServerId(_ serverId: String) async throws

    /// DELETE FROM taches WHERE localId = :localId
    func deleteByLocalId(_ localId: Int64) async throws

    /// SELECT * FROM taches WHERE projetServerId = :projetServerId
    func listByProjetServerId(_ projetServerId: String) async throws -> [TacheEntity]

    /// Kotlin `observeByProjetServerId(...): Flow<List<TacheEntity>>` — manual refresh model.
    /// SELECT * FROM taches WHERE projetServerId = :projetServerId ORDER BY ordre ASC
    func fetchByProjetServerId(_ projetServerId: String) async throws -> [TacheEntity]

    /// SELECT * FROM taches
    func listAll() async throws -> [TacheEntity]
}