RdvDao.swift 29 lignes · 990 octets
import Foundation

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

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

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

    /// SELECT * FROM rdv WHERE calendarEventId = :calendarEventId
    func getByCalendarEventId(_ calendarEventId: Int64) async throws -> RdvEntity?

    /// SELECT * FROM rdv WHERE dirtyLocal = 1
    func listDirty() async throws -> [RdvEntity]

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

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

    /// SELECT * FROM rdv
    func listAll() async throws -> [RdvEntity]
}