Skip to content

Commit a6394c1

Browse files
authored
Add example for idle_timeout docs (porsager#171)
1 parent 182b6f1 commit a6394c1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,15 @@ There are no guarantees about queries executing in order unless using a transact
600600

601601
### Idle timeout
602602

603-
Connections will by default not close until `.end()` is called, but often it is useful to have them close when there is no activity or if using Postgres.js in eg. Lamdas. This can be done using the `idle_timeout` option to specify the amount of seconds to wait before automatically closing an idle connection.
603+
Connections will by default not close until `.end()` is called, but often it is useful to have them close when there is no activity or if using Postgres.js in eg. Lamdas / Serverless environments. This can be done using the `idle_timeout` option to specify the amount of seconds to wait before automatically closing an idle connection.
604+
605+
For example, to close idle connections after 2 seconds:
606+
607+
```js
608+
const sql = postgres({
609+
idle_timeout: 2
610+
})
611+
```
604612

605613
## Prepared statements
606614

0 commit comments

Comments
 (0)