SyncOpDao.swift 20 lignes · 674 octets
import Foundation

/// Port of the Room `SyncOpDao`.
protocol SyncOpDao {
    /// INSERT OR REPLACE INTO sync_ops; returns the row id.
    @discardableResult
    func insert(_ entity: SyncOpEntity) async throws -> Int64

    /// SELECT * FROM sync_ops ORDER BY createdAt ASC
    func listAll() async throws -> [SyncOpEntity]

    /// SELECT * FROM sync_ops WHERE id = :id
    func getById(_ id: Int64) async throws -> SyncOpEntity?

    /// UPDATE sync_ops SET attempts = attempts + 1, lastError = :error WHERE id = :id
    func markFailure(id: Int64, error: String?) async throws

    /// DELETE FROM sync_ops WHERE id = :id
    func deleteById(_ id: Int64) async throws
}