@@ -15,7 +15,6 @@ var ConnectionParameters = require('./connection-parameters');
1515var poolFactory = require ( './pool-factory' ) ;
1616
1717var PG = function ( clientConstructor ) {
18- EventEmitter . call ( this ) ;
1918 this . defaults = defaults ;
2019 this . Client = clientConstructor ;
2120 this . Query = this . Client . Query ;
@@ -25,74 +24,6 @@ var PG = function(clientConstructor) {
2524 this . types = require ( 'pg-types' ) ;
2625} ;
2726
28- util . inherits ( PG , EventEmitter ) ;
29-
30- PG . prototype . end = util . deprecate ( function ( ) {
31- var self = this ;
32- var keys = Object . keys ( this . _pools ) ;
33- var count = keys . length ;
34- if ( count === 0 ) {
35- self . emit ( 'end' ) ;
36- } else {
37- keys . forEach ( function ( key ) {
38- var pool = self . _pools [ key ] ;
39- delete self . _pools [ key ] ;
40- pool . pool . drain ( function ( ) {
41- pool . pool . destroyAllNow ( function ( ) {
42- count -- ;
43- if ( count === 0 ) {
44- self . emit ( 'end' ) ;
45- }
46- } ) ;
47- } ) ;
48- } ) ;
49- }
50- } ,
51- 'pg.end() is deprecated - please construct pools directly via new pg.Pool()' ) ;
52-
53- PG . prototype . connect = util . deprecate ( function ( config , callback ) {
54- if ( typeof config == "function" ) {
55- callback = config ;
56- config = null ;
57- }
58- if ( typeof config == 'string' ) {
59- config = new ConnectionParameters ( config ) ;
60- }
61-
62- config = config || { } ;
63-
64- //for backwards compatibility
65- config . max = config . max || config . poolSize || defaults . poolSize ;
66- config . idleTimeoutMillis = config . idleTimeoutMillis || config . poolIdleTimeout || defaults . poolIdleTimeout ;
67- config . log = config . log || config . poolLog || defaults . poolLog ;
68-
69- var poolName = JSON . stringify ( config ) ;
70- this . _pools [ poolName ] = this . _pools [ poolName ] || new this . Pool ( config ) ;
71- var pool = this . _pools [ poolName ] ;
72- if ( ! pool . listeners ( 'error' ) . length ) {
73- //propagate errors up to pg object
74- pool . on ( 'error' , function ( e ) {
75- this . emit ( 'error' , e , e . client ) ;
76- } . bind ( this ) ) ;
77- }
78- return pool . connect ( callback ) ;
79- } ,
80- 'pg.connect() is deprecated - please construct pools directly via new pg.Pool()' ) ;
81-
82- // cancel the query running on the given client
83- PG . prototype . cancel = util . deprecate ( function ( config , client , query ) {
84- if ( client . native ) {
85- return client . cancel ( query ) ;
86- }
87- var c = config ;
88- //allow for no config to be passed
89- if ( typeof c === 'function' ) {
90- c = defaults ;
91- }
92- var cancellingClient = new this . Client ( c ) ;
93- cancellingClient . cancel ( client , query ) ;
94- } , 'pg.cancel() is deprecated - please create your own client instances to cancel queries' ) ;
95-
9627if ( typeof process . env . NODE_PG_FORCE_NATIVE != 'undefined' ) {
9728 module . exports = new PG ( require ( './native' ) ) ;
9829} else {
0 commit comments