Skip to content

Commit d5db1ea

Browse files
authored
Update 1-connecting.mdx
Documentation should mention supported feature. brianc/node-postgres#2513
1 parent 40393b8 commit d5db1ea

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: content/features/1-connecting.mdx

+14
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ client.query('SELECT NOW()', (err, res) => {
9090
})
9191
```
9292

93+
Many cloud providers also provide alternative methods of connecting to database instances using short-lived authentication tokens. node-postgres supports dynamic passwords via a callback function, either synchronous or asynchronous. The callback function must resolve to a string.
94+
95+
```
96+
97+
const pool = new pg.Pool({
98+
host: 'db.example.com',
99+
port: 5432,
100+
user: 'user',
101+
database: 'my-db',
102+
password: async () => 'random-' + Date.now(),
103+
});
104+
105+
```
106+
93107
### Programmatic Connection to Sockets
94108

95109
Connections to unix sockets can also be made. This can be useful on distros like Ubuntu, where authentication is managed via the socket connection instead of a password.

0 commit comments

Comments
 (0)