You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pg-pool supports a fully promise-based api for acquiring clients
44
48
45
49
```js
@@ -56,6 +60,8 @@ pool.connect().then(client => {
56
60
})
57
61
```
58
62
63
+
### plays nice with async/await
64
+
59
65
this ends up looking much nicer if you're using [co](https://github.com/tj/co) or async/await:
60
66
61
67
```js
@@ -69,6 +75,8 @@ try {
69
75
}
70
76
```
71
77
78
+
### your new favorite helper method
79
+
72
80
because its so common to just run a query and return the client to the pool afterward pg-pool has this built-in:
73
81
74
82
```js
@@ -82,7 +90,9 @@ have some other edge case like [streaming rows](https://github.com/brianc/node-p
82
90
you should almost always just use `pool.query`. Its easy, it does the right thing :tm:, and wont ever forget to return
83
91
clients back to the pool after the query is done.
84
92
85
-
pg-pool still and will always support the traditional callback api for acquiring a client that node-postgres has shipped with internally for years:
93
+
### drop-in backwards compatible
94
+
95
+
pg-pool still and will always support the traditional callback api for acquiring a client. This is the exact API node-postgres has shipped with internally for years:
That means you can drop pg-pool into your app and 99% of the cases you wont even notice a difference. In fact, very soon I will be using pg-pool internally within node-postgres itself!
103
113
114
+
### shut it down
115
+
104
116
When you are finished with the pool if all the clients are idle the pool will close them after `config.idleTimeoutMillis` and your app
105
117
will shutdown gracefully. If you don't want to wait for the timeout you can end the pool as follows:
0 commit comments