manageable-users/Sources/ManagableUsers/Utilities/Request+SQLDatabase.swift

15 lines
452 B
Swift

import Fluent
import SQLKit
extension Database {
public func withSQLConnection<T: Sendable>(_ closure: @escaping @Sendable (SQLDatabase) async throws -> T) async throws -> T {
return try await self.withConnection { database in
guard let connection = database as? SQLDatabase else {
throw NoSQLDatabaseError (database: database)
}
return try await closure (connection)
}
}
}