Skip to content

Commit

Permalink
feat: use reserved connections. (#5)
Browse files Browse the repository at this point in the history
* install from reserve branch.

* use reserve in driver/connection.

* temp fix postgres not installing.

* misc

* use specific commit.

* remove caveats from readme.

* bump postgres version.

* use ReservedSql.

* update peer dependency.

* remove excess install deps stuff.

* install pnpm 8 in ci.

* drop node 14.

* install pnpm 8 in ci.
  • Loading branch information
igalklebanov authored Oct 26, 2023
1 parent ffe3124 commit 824a2e6
Show file tree
Hide file tree
Showing 7 changed files with 476 additions and 495 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [16.x, 18.x, 20.x]
fail-fast: false

steps:
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 7
version: 8
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 7
version: 8
run_install: false

- name: Get pnpm store directory
Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,6 @@ const db = new Kysely<Database>({
})
```

## Caveats

### Single connection

[Postgres.js](https://github.com/porsager/postgres) doesn't provide single connection getter method/s. To get a single connection, you have to create an instance with a pool that has at most one connection (`max: 1`). This is not aligned with Kysely's current design. As a result, `db.connection()` will not work as expected when using a pool with more than one connection.
If you need to use a single connection, you should instantiate a new `Kysely`
instance with a pool that has at most one connection.

### Transactions

For transactions, this dialect creates additional pools with at most one connection, so `db.transaction().execute(...)` will work as expected. Keep in mind, this means that total number of connections to the database might exceed the pool size passed to Kysely initially.

## License

MIT License, see `LICENSE`
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"peerDependencies": {
"kysely": ">= 0.24.0 < 1",
"postgres": ">= 3.0.0 < 4"
"postgres": ">= 3.4.0 < 4"
},
"devDependencies": {
"@tsconfig/node18": "^1.0.1",
Expand All @@ -59,7 +59,7 @@
"kysely": "^0.24.2",
"mocha": "^10.2.0",
"mocha-each": "^2.0.1",
"postgres": "^3.3.4",
"postgres": "^3.4.1",
"prettier": "^2.8.7",
"prettier-plugin-organize-imports": "^3.2.2",
"prettier-plugin-pkg": "^0.17.1",
Expand Down
Loading

0 comments on commit 824a2e6

Please sign in to comment.