
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
kysely-postgres-js
Advanced tools
Kysely dialect for PostgreSQL using the Postgres.js client under the hood.
npm i kysely-postgres-js
npm i kysely-postgres-js kysely postgres
yarn add kysely-postgres-js kysely postgres
pnpm add kysely-postgres-js kysely postgres
This package uses/extends some Kysely types and classes, which are imported using its NPM package name -- not a relative file path or CDN url. It also uses [Postgres.js] which is imported using its NPM package name -- not a relative file path or CDN url.
To fix that, add an import_map.json
file.
{
"imports": {
"kysely": "https://cdn.jsdelivr.net/npm/kysely@0.23.5/dist/esm/index.js",
"postgres": "https://deno.land/x/postgres@3.3.4"
}
}
import {Kysely} from 'kysely'
import {PostgresJSDialect} from 'kysely-postgres-js'
import postgres from 'postgres'
interface Database {
person: {
id: GeneratedAlways<number>
first_name: string | null
last_name: string | null
age: number
}
}
const db = new Kysely<Database>({
dialect: new PostgresJSDialect({
options: {
database: 'test',
host: 'localhost',
port: 5434,
user: 'admin',
},
postgres,
}),
})
Postgres.js 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.
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.
MIT License, see LICENSE
FAQs
Kysely dialect for PostgreSQL using the Postgres.js client
The npm package kysely-postgres-js receives a total of 12,386 weekly downloads. As such, kysely-postgres-js popularity was classified as popular.
We found that kysely-postgres-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.