15 lines
452 B
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)
|
|
}
|
|
}
|
|
}
|