ReservationDao.swift 32 lignes · 1307 octets
import Foundation

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

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

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

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

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

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

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

    /// SELECT * FROM reservations WHERE cibleType = :cibleType AND cibleId = :cibleId
    func listByCible(cibleType: String, cibleId: String) async throws -> [ReservationEntity]

    /// SELECT * FROM reservations
    func listAll() async throws -> [ReservationEntity]
}