File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 8
8
9
9
extension Knex {
10
10
11
+ public func fetch< T: CollectionType > ( trx: Connection ? = nil ) throws -> T ? {
12
+ guard let rows = try execute ( . select, trx) . asResultSet ( ) else {
13
+ return nil
14
+ }
15
+ return try T ( rows: rows)
16
+ }
17
+
11
18
public func fetch< T: Entity > ( trx: Connection ? = nil ) throws -> [ T ] {
12
19
let rows = try execute ( . select, trx) . asResultSet ( )
13
20
return try rows? . map { try T ( row: $0) } ?? [ ]
Original file line number Diff line number Diff line change
1
+ //
2
+ // Collection.swift
3
+ // SwiftJNChatApp
4
+ //
5
+ // Created by Yuki Takei on 2017/02/20.
6
+ //
7
+ //
8
+
9
+ public protocol CollectionSerializable {
10
+ func serialize( ) throws -> [ [ String : Any ] ]
11
+ }
12
+
13
+ public protocol CollectionType {
14
+ init ( rows: ResultSet ) throws
15
+ }
16
+
File renamed without changes.
You can’t perform that action at this time.
0 commit comments