@@ -34,8 +34,22 @@ export class DriverFactory {
3434 . set ( 'postgres' , { Driver : PostgresDriver } )
3535 . set ( 'sqlserver' , { Driver : SqlServerDriver } )
3636
37- static availableDrivers ( ) : string [ ] {
38- return [ ...this . drivers . keys ( ) ]
37+ static availableDrivers ( onlyConnected = false ) : string [ ] {
38+ const availableDrivers = [ ]
39+
40+ for ( const [ key , value ] of this . drivers . entries ( ) ) {
41+ if ( onlyConnected ) {
42+ if ( ! value . clientConnection ) continue
43+
44+ availableDrivers . push ( key )
45+
46+ continue
47+ }
48+
49+ availableDrivers . push ( key )
50+ }
51+
52+ return availableDrivers
3953 }
4054
4155 static fabricate ( conName : string , runtimeConfig : any = { } ) : DriverContract {
@@ -86,9 +100,6 @@ export class DriverFactory {
86100 else await client . destroy ( )
87101
88102 driverObject . clientConnection = null
89- driverObject . Driver = new driverObject . Driver (
90- Config . get ( 'database.default' ) ,
91- )
92103
93104 this . drivers . set ( driverName , driverObject )
94105 }
@@ -101,7 +112,6 @@ export class DriverFactory {
101112 const driverObject = this . drivers . get ( driverName )
102113
103114 driverObject . clientConnection = clientConnection
104- driverObject . Driver = new driverObject . Driver ( clientConnection )
105115
106116 this . drivers . set ( driverName , driverObject )
107117 }
0 commit comments