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
Fastify PostgreSQL connection plugin; with this, you can share the same PostgreSQL connection pool in every part of your server.
8
-
Under the hood [node-postgres](https://github.com/brianc/node-postgres) is used, the options that you pass to `register` will be passed to the PostgreSQL pool builder.
8
+
Under the hood [node-postgres](https://github.com/brianc/node-postgres) is used, and the options that you pass to `register` will be passed to the PostgreSQL pool builder.
As you can see there is no need to close the client, since it is done internally. Promises and async await are supported as well.
153
+
As you can see there is no need to close the client since it is done internally. Promises and async await are supported as well.
154
154
155
155
### Name option
156
156
If you need to have multiple databases set up, then you can name each one of them by passing `name: 'foo'`. It will then be accessible as `fastify.pg.foo`.
If you want to provide your own `pg` module, for example to support packages like [`pg-range`](https://www.npmjs.com/package/pg-range), you can provide an optional `pg` option with the patched library to use:
211
+
If you want to provide your own `pg` module, for example, to support packages like [`pg-range`](https://www.npmjs.com/package/pg-range), you can provide an optional `pg` option with the patched library to use:
212
212
213
213
```js
214
214
constfastify=require('fastify')()
@@ -307,7 +307,7 @@ $ npm test
307
307
DATABASE_TEST_URL="postgres://username:password@localhost/something_thats_a_test_database" npm test
0 commit comments