@@ -38,16 +38,18 @@ type QueryResult = {
3838 rows : Row [ ] ,
3939} ;
4040
41+ type Client = AnySql & { events : EventEmitter , } ;
42+
4143export const createBridge = ( postgres : typeof Postgres ) => {
4244 return class PostgresBridge {
4345 private readonly poolEvents : EventEmitter ;
4446
45- private readonly pool : GenericPool < AnySql & { events : EventEmitter , } > ;
47+ private readonly pool : GenericPool < Client > ;
4648
4749 public constructor ( poolConfiguration : PgPool ) {
4850 this . poolEvents = new EventEmitter ( ) ;
4951
50- this . pool = genericPool . createPool < AnySql & { events : EventEmitter , } > ( {
52+ this . pool = genericPool . createPool < Client > ( {
5153 create : async ( ) => {
5254 const connectionEvents = new EventEmitter ( ) ;
5355
@@ -71,7 +73,7 @@ export const createBridge = (postgres: typeof Postgres) => {
7173 port : poolConfiguration . port ?? 5_432 ,
7274 ssl : poolConfiguration . ssl ,
7375 username : poolConfiguration . user ,
74- } ) as AnySql & { events : EventEmitter , } ;
76+ } ) as Client ;
7577
7678 connection . events = connectionEvents ;
7779
@@ -131,6 +133,11 @@ export const createBridge = (postgres: typeof Postgres) => {
131133 await client . end ( ) ;
132134 }
133135
136+ public _clients ( ) {
137+ // @ts -expect-error accessing private method
138+ return Array . from ( this . pool . _allObjects ) ;
139+ }
140+
134141 public get idleCount ( ) {
135142 return this . pool . available ;
136143 }
0 commit comments