From 2e13ef1f934beda6f70ccad958e0dd66e9457800 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Sat, 3 Apr 2021 19:41:17 +0200 Subject: [PATCH 1/2] Add example for idle_timeout docs --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 831ff1e0..ced2c36f 100644 --- a/README.md +++ b/README.md @@ -600,7 +600,15 @@ There are no guarantees about queries executing in order unless using a transact ### Idle timeout -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. +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. + +For example, to close idle connections after 2 seconds: + +```js +const sql = postgres({ + timeout: 2 +}) +``` ## Prepared statements From 87967e62b827c7a087d5f9777fa5ab52711832df Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Sun, 4 Apr 2021 00:44:20 +0200 Subject: [PATCH 2/2] Fix option --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ced2c36f..3102b627 100644 --- a/README.md +++ b/README.md @@ -606,7 +606,7 @@ For example, to close idle connections after 2 seconds: ```js const sql = postgres({ - timeout: 2 + idle_timeout: 2 }) ```