File tree Expand file tree Collapse file tree 1 file changed +18
-15
lines changed
Sources/FluentPostgresDriver Expand file tree Collapse file tree 1 file changed +18
-15
lines changed Original file line number Diff line number Diff line change 11import FluentSQL
22
3- #warning("TODO: fix to allow conformance")
4- struct SQLOutput : FluentOutput {
5- let row : SQLRow
6-
7- var description : String {
8- return " \( self . row) "
9- }
10-
11- public init ( row: SQLRow ) {
12- self . row = row
3+ extension FluentDatabaseID {
4+ public static var psql : FluentDatabaseID {
5+ return . init( string: " psql " )
136 }
14-
15- func decode< T> ( field: String , as type: T . Type ) throws -> T where T : Decodable {
16- return try self . row. decode ( column: field, as: T . self)
7+ }
8+
9+ extension FluentDatabases {
10+ public mutating func postgres(
11+ config: PostgresDatabase . Config ,
12+ poolConfig: ConnectionPoolConfig = . init( ) ,
13+ as id: FluentDatabaseID = . psql,
14+ isDefault: Bool = true
15+ ) {
16+ let driver = PostgresDriver ( connectionPool: . init(
17+ config: poolConfig,
18+ source: . init( config: config, on: self . eventLoop)
19+ ) )
20+ self . add ( driver, as: id, isDefault: isDefault)
1721 }
1822}
1923
@@ -37,8 +41,7 @@ public struct PostgresDriver: FluentDatabase {
3741 default : break
3842 }
3943 return connection. sqlQuery ( sql) { row in
40- let output = SQLOutput ( row: row)
41- try onOutput ( output)
44+ try onOutput ( row. fluentOutput)
4245 }
4346 }
4447 }
You can’t perform that action at this time.
0 commit comments