File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ export interface PoolConfig extends ClientConfig {
5454 maxUses ?: number | undefined ;
5555 maxLifetimeSeconds ?: number | undefined ;
5656 Client ?: ( new ( ) => ClientBase ) | undefined ;
57+ onConnect ?: ( ( client : ClientBase ) => void ) | undefined ;
5758}
5859
5960export interface QueryConfig < I = any [ ] > {
Original file line number Diff line number Diff line change 11{
22 "private" : true ,
33 "name" : " @types/pg" ,
4- "version" : " 8.18 .9999" ,
4+ "version" : " 8.20 .9999" ,
55 "projects" : [
66 " https://github.com/brianc/node-postgres"
77 ],
Original file line number Diff line number Diff line change @@ -432,3 +432,16 @@ const bindConfig = {
432432
433433const con = new Connection ( ) ;
434434con . bind ( bindConfig , true ) ;
435+
436+ const poolWithOnConnect = new Pool ( {
437+ onConnect : ( client ) => {
438+ client . query ( "SELECT 1" ) . then ( result => {
439+ console . log ( result . rows [ 0 ] . number ) ;
440+ } ) ;
441+ console . log ( "onConnect callback is working!" ) ;
442+ } ,
443+ } ) ;
444+
445+ poolWithOnConnect . connect ( ) . then ( client => {
446+ console . log ( "client connected" ) ;
447+ } ) ;
You can’t perform that action at this time.
0 commit comments