Skip to main content
Version: 3.x

PostgreSQL

Installing driver​

npm install pg
npm install --save-dev @types/pg

Creating ZenStackClient​

import { schema } from './zenstack/schema';
import { Pool } from 'pg';
import { ZenStackClient } from '@zenstackhq/orm';
import { PostgresDialect } from '@zenstackhq/orm/dialects/postgres';

const db = new ZenStackClient(schema, {
dialect: new PostgresDialect({
pool: new Pool({
connectionString: process.env.DATABASE_URL,
}),
}),
});

Using PGlite​

No Official Support

The PGlite dialect is not officially supported or tested by ZenStack, but you may evaluate it and report your findings and interest on the GitHub issue.

npm install @electric-sql/pglite kysely
import { schema } from './zenstack/schema';
import { PGlite } from '@electric-sql/pglite';
import { ZenStackClient } from '@zenstackhq/orm';
import { PGliteDialect } from 'kysely';

const db = new ZenStackClient(schema, {
dialect: new PGliteDialect({
pglite: new PGlite(),
}),
});
Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below