@@ -80,6 +80,57 @@ await db.select().from(...);
8080See the [ Drizzle documentation] ( https://orm.drizzle.team/docs/connect-pglite )
8181for more details.
8282
83+ ## Kysely
84+
85+ [ Kysely] ( https://kysely.dev ) is a ** type-safe** TypeScript SQL query builder
86+ with support for many databases, including PGlite. Features include:
87+
88+ - End-to-end type-safety and autocompletion
89+ - Composable, predictable, escape-rich, fluent API.
90+ - Cancellable, pluggable, hookable.
91+ - Migrations and DDL builders too.
92+ - Built-in PGlite dialect (since Kysely ` 0.29.0 ` )
93+
94+ To use Kysely with PGlite, install ` kysely ` (>= 0.29) alongside ` @electric-sql/pglite ` :
95+
96+ ``` bash
97+ npm i @electric-sql/pglite kysely
98+ ```
99+
100+ Then create a Kysely instance using the built-in ` PGliteDialect ` :
101+
102+ ``` ts
103+ import { PGlite } from ' @electric-sql/pglite'
104+ import { Kysely , PGliteDialect } from ' kysely'
105+
106+ // See https://kysely.dev/docs/generating-types
107+ interface Database {
108+ person: {
109+ id: string
110+ }
111+ }
112+
113+ const db = new Kysely <Database >({
114+ dialect: new PGliteDialect ({
115+ pglite: new PGlite (),
116+ }),
117+ })
118+
119+ const people = await db .selectFrom (' person' ).selectAll ().execute ()
120+ ```
121+
122+ ` pglite ` can also be a function (sync or async), in which case the PGlite
123+ instance is created lazily the first time a query runs:
124+
125+ ``` ts
126+ new PGliteDialect ({
127+ pglite : () => new PGlite (' ./path/to/pgdata' ),
128+ })
129+ ```
130+
131+ See the [ Kysely documentation] ( https://kysely.dev/docs/getting-started?dialect=pglite )
132+ for more details.
133+
83134## Knex.js
84135
85136[ Knex] ( https://knexjs.org/ ) is a stable, reliable Query Builder for various
0 commit comments