Skip to content

Commit 6157a60

Browse files
authored
Merge pull request #1247 from dhensby/pulls/pool-docs
DOCS Update pool management example
2 parents fcb6e79 + cb3fa4d commit 6157a60

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,17 +439,20 @@ const POOLS = {}
439439

440440
function createPool(config, name) {
441441
if (getPool(name)) {
442-
throw new Error('Pool with this name already exists')
442+
return Promise.reject(new Error('Pool with this name already exists'))
443443
}
444-
return POOLS[name] = (new ConnectionPool(config)).connect()
444+
return (new ConnectionPool(config)).connect().then((pool) => {
445+
return POOLS[name] = pool
446+
})
445447
}
446448

447449
function closePool(name) {
448-
if (Object.prototype.hasOwnProperty.apply(POOLS, name)) {
449-
const pool = POOLS[name];
450-
delete POOLS[name];
450+
const pool = getPool(name)
451+
if (pool) {
452+
delete POOLS[name]
451453
return pool.close()
452454
}
455+
return Promise.resolve()
453456
}
454457

455458
function getPool(name) {

0 commit comments

Comments
 (0)