Skip to main content
Version: 3.0 Beta

SQLite

Node.js​

Installing driver​

npm install better-sqlite3
npm install --save-dev @types/better-sqlite3

Creating ZenStackClient​

import { schema } from './zenstack/schema';
import SQLite from 'better-sqlite3';
import { ZenStackClient } from '@zenstackhq/orm';
import { SqliteDialect } from '@zenstackhq/orm/dialects/sqlite';

const db = new ZenStackClient(schema, {
dialect: new SqliteDialect({ database: new SQLite('./dev.db') }),
});

Bun​

Installing driver​

Bun is not compatible with better-sqlite3. You can use its builtin bun:sqlite module with the kysely-bun-sqlite Kysely community dialect.

npm install kysely-bun-sqlite

Creating ZenStackClient​

import { schema } from './zenstack/schema';
import { Database } from 'bun:sqlite';
import { ZenStackClient } from '@zenstackhq/orm';
import { BunSqliteDialect } from 'kysely-bun-sqlite';

const db = new ZenStackClient(schema, {
dialect: new BunSqliteDialect({ database: new Database('./dev.db') }),
});
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