Kysely dialect for PostgreSQL using the Postgres.js client library under the hood (version >= 3.4).
This dialect should not be confused with Kysely's built-in PostgreSQL dialect, which uses the pg client library instead.
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/[email protected]/dist/esm/index.js",
"postgres": "https://deno.land/x/[email protected]/mod.js"
}
}
import {type GeneratedAlways, 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({
postgres: postgres({
database: 'test',
host: 'localhost',
max: 10,
port: 5434,
user: 'admin',
}),
}),
})
MIT License, see LICENSE