File tree Expand file tree Collapse file tree 2 files changed +41
-5
lines changed
Expand file tree Collapse file tree 2 files changed +41
-5
lines changed Original file line number Diff line number Diff line change @@ -4,17 +4,17 @@ import Vapor
44private let fluentDatabaseKey = " fluent-vapor-database "
55
66extension Droplet {
7- internal var database : Database ? {
7+ public internal( set ) var database : Database ? {
88 get {
99 return storage [ fluentDatabaseKey] as? Database
1010 }
1111 set {
1212 storage [ fluentDatabaseKey] = newValue
1313 }
1414 }
15-
16-
17- func assertDatabase( ) throws -> Database {
15+
16+
17+ public func assertDatabase( ) throws -> Database {
1818 guard let database = self . database else {
1919 throw FluentProviderError . noDatabase
2020 }
@@ -26,3 +26,32 @@ extension Droplet {
2626public enum FluentProviderError : Error {
2727 case noDatabase
2828}
29+
30+ extension FluentProviderError : Debuggable {
31+ public var reason : String {
32+ switch self {
33+ case . noDatabase:
34+ return " No database has been configured. "
35+ }
36+ }
37+
38+ public var identifier : String {
39+ switch self {
40+ case . noDatabase:
41+ return " noDatabase "
42+ }
43+ }
44+
45+ public var possibleCauses : [ String ] {
46+ switch self {
47+ case . noDatabase:
48+ return [
49+ " You have not added the `MySQLProvider.Provider` to your Droplet. "
50+ ]
51+ }
52+ }
53+
54+ public var suggestedFixes : [ String ] {
55+ return [ ]
56+ }
57+ }
Original file line number Diff line number Diff line change @@ -138,7 +138,14 @@ public final class Provider: Vapor.Provider {
138138 // add configurable driver types, this must
139139 // come before the preparation calls
140140 let driver = try drop. config. resolveDriver ( )
141- let database = Database ( driver)
141+
142+ let database : Database
143+ if let maxConnections = drop. config [ " fluent " , " maxConnections " ] ? . int {
144+ database = Database ( driver, maxConnections: maxConnections)
145+ } else {
146+ database = Database ( driver)
147+ }
148+
142149 drop. database = database
143150
144151 if let m = self . migrationEntityName {
You can’t perform that action at this time.
0 commit comments