File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ const postgres = require('postgres/cjs')
41
41
42
42
const sql = postgres (' postgres://user:pass@host:port/database' , {
43
43
ssl : false , // True, or an object with options to tls.connect
44
- connections : 10 , // Max number of connections
44
+ max : 10 , // Max number of connections
45
45
timeout : 0 , // Idle connection timeout in seconds
46
46
types : [], // Custom types, see section below
47
47
onconnect : null , // Runs before any queries on each connect
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export default function Postgres(url, options) {
18
18
let ready = false
19
19
, ended = null
20
20
, arrayTypesPromise
21
- , max = Math . max ( 1 , options . connections || options . max )
21
+ , max = Math . max ( 1 , options . max )
22
22
, listener
23
23
24
24
const connections = Queue ( )
@@ -152,9 +152,9 @@ export default function Postgres(url, options) {
152
152
}
153
153
154
154
function getConnection ( reserve ) {
155
- const connection = connections . shift ( ) || ( -- max && createConnection ( options ) )
155
+ const connection = -- max >= 0 ? createConnection ( options ) : connections . shift ( )
156
156
! options . fifo && ! reserve && connection && connections . push ( connection )
157
- connection . active = ! ( options . onconnect && ! connection . ready )
157
+ connection && ( connection . active = ! ( options . onconnect && ! connection . ready ) )
158
158
return options . onconnect && ! connection . ready
159
159
? instance ( { fn : options . onconnect } , connection )
160
160
: connection
You can’t perform that action at this time.
0 commit comments