Skip to content

Commit 2d43606

Browse files
committed
Upgrade to latest Bridges
1 parent b347744 commit 2d43606

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

Sources/MySQLBridge/Extensions/DatabaseIdentifier+Initialization.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@ public class MySQLDatabaseIdentifier: DatabaseIdentifier, MySQLDatabaseIdentifia
4040
T.select.execute(on: conn).first(decoding: T.self)
4141
}
4242
}
43+
44+
public func query(_ query: SwifQLable, on bridges: AnyBridgesObject) -> EventLoopFuture<[BridgesRow]> {
45+
MySQLBridge(bridges.bridges.bridge(to: B.self, on: bridges.eventLoop)).connection(to: self) { conn in
46+
query.execute(on: conn).map { $0 as [BridgesRow] }
47+
}
48+
}
4349
}

Sources/MySQLBridge/Extensions/Row+Decode.swift

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@
66
//
77

88
import Foundation
9+
import Bridges
910

10-
extension EventLoopFuture where Value == [MySQLRow] {
11-
public func first<R>(decoding type: R.Type) -> EventLoopFuture<R?> where R: Decodable {
12-
flatMapThrowing { try $0.first(as: type) }
13-
}
14-
15-
public func all<R>(decoding type: R.Type) -> EventLoopFuture<[R]> where R: Decodable {
16-
flatMapThrowing { try $0.all(as: type) }
17-
}
18-
}
19-
20-
extension Array where Element == MySQLRow {
21-
public func first<R>(as type: R.Type) throws -> R? where R: Decodable {
22-
try first?.decode(model: type)
23-
}
24-
25-
public func all<R>(as type: R.Type) throws -> [R] where R: Decodable {
26-
try map { try $0.decode(model: type) }
27-
}
28-
}
11+
extension MySQLRow: BridgesRow {}

0 commit comments

Comments
 (0)