Skip to content

Commit 8245ea0

Browse files
authored
docs: add example to use existing conn pool (#1419)
1 parent 22c7e13 commit 8245ea0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

libs/checkpoint-postgres/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@ for await (const checkpoint of checkpointer.list(readConfig)) {
6565
}
6666
```
6767

68+
## Usage with existing connection pool
69+
70+
```ts
71+
import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";
72+
import pg from "pg";
73+
74+
// You can use any existing postgres connection pool
75+
// we create a new pool here for the sake of the example
76+
const pool = new pg.Pool({
77+
connectionString: "postgresql://..."
78+
});
79+
80+
const checkpointer = new PostgresSaver(pool, undefined, {
81+
schema: "schema_name"
82+
});
83+
84+
await checkpointer.setup();
85+
86+
// ...
87+
```
88+
6889
## Testing
6990

7091
Spin up testing PostgreSQL

0 commit comments

Comments
 (0)