Skip to content

Commit 300e15b

Browse files
author
Simone Sanfratello
committed
feature: native option
1 parent d25969b commit 300e15b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ fastify.listen(3000, err => {
9696
As you can see there is no need to close the client, since is done internally. Promises and async await are supported as well.
9797

9898
### Native option
99-
Use native libpq to gain high performance; it will use [pg-native](https://github.com/brianc/node-pg-native) instead of [pg](https://github.com/brianc/node-pg).
99+
Use native `libpq` to gain high performance; it will use [pg-native](https://github.com/brianc/node-pg-native) instead of [pg](https://github.com/brianc/node-pg).
100100
Note: it requires PostgreSQL client libraries & tools installed, see
101-
[instructions](https://github.com/brianc/node-pg-native#install).
101+
[instructions](https://github.com/brianc/node-pg-native#install).
102+
Note: trying to use native options without successfully installation of `pg-native` will get a warning and fallback to regular `pg` module.
102103

103104
```js
104105
const fastify = require('fastify')

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ let pg = require('pg')
55

66
function fastifyPostgres (fastify, options, next) {
77
if (options.native) {
8+
delete options.native
89
if (!pg.native) {
9-
console.warn('pg-native not installed, can\'t use native option')
10+
console.warn('pg-native not installed, can\'t use native option - fallback to pg module')
1011
} else {
1112
pg = pg.native
1213
}

0 commit comments

Comments
 (0)