Files
Termind/TFM/Infrastructure/Database/ModelContext+Commit.swift
T
2026-09-12 23:57:33 +08:00

15 lines
258 B
Swift

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