-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Concurrency extensions for SQLKit. Not much needed here! (#140)
- Loading branch information
Showing
4 changed files
with
827 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#if compiler(>=5.5) && canImport(_Concurrency) | ||
import NIOCore | ||
|
||
@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *) | ||
public extension SQLDatabase { | ||
func execute(sql query: SQLExpression, _ onRow: @escaping (SQLRow) -> ()) async throws -> Void { | ||
try await self.execute(sql: query, onRow).get() | ||
} | ||
} | ||
|
||
#endif |
11 changes: 11 additions & 0 deletions
11
Sources/SQLKit/Concurrency/SQLQueryBuilder+Concurrency.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#if compiler(>=5.5) && canImport(_Concurrency) | ||
import NIOCore | ||
|
||
@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *) | ||
public extension SQLQueryBuilder { | ||
func run() async throws -> Void { | ||
return try await self.run().get() | ||
} | ||
} | ||
|
||
#endif |
31 changes: 31 additions & 0 deletions
31
Sources/SQLKit/Concurrency/SQLQueryFetcher+Concurrency.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#if compiler(>=5.5) && canImport(_Concurrency) | ||
import NIOCore | ||
|
||
@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *) | ||
public extension SQLQueryFetcher { | ||
func first<D>(decoding: D.Type) async throws -> D? where D: Decodable { | ||
return try await self.first(decoding: D.self).get() | ||
} | ||
|
||
func first() async throws -> SQLRow? { | ||
return try await self.first().get() | ||
} | ||
|
||
func all<D>(decoding: D.Type) async throws -> [D] where D: Decodable { | ||
return try await self.all(decoding: D.self).get() | ||
} | ||
|
||
func all() async throws -> [SQLRow] { | ||
return try await self.all().get() | ||
} | ||
|
||
func run<D>(decoding: D.Type, _ handler: @escaping (Result<D, Error>) -> ()) async throws -> Void where D: Decodable { | ||
return try await self.run(decoding: D.self, handler).get() | ||
} | ||
|
||
func run(_ handler: @escaping (SQLRow) -> ()) async throws -> Void { | ||
return try await self.run(handler).get() | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.