Files
Termind/TFM/Infrastructure/Database/ModelContext+Commit.swift
T

19 lines
326 B
Swift

import SwiftData
@MainActor
extension ModelContext {
func savePendingChanges() throws {
try commit {}
}
func commit(_ operation: () throws -> Void) throws {
do {
try operation()
try save()
} catch {
rollback()
throw error
}
}
}