ProjetDao.swift 24 lignes · 855 octets
import Foundation

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

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

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

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

    /// SELECT * FROM projets
    func listAll() async throws -> [ProjetEntity]

    /// Kotlin `observeAll(): Flow<List<ProjetEntity>>` — manual refresh model.
    /// SELECT * FROM projets ORDER BY nom ASC
    func fetchAll() async throws -> [ProjetEntity]
}