The entry point: a synchronous, module-load-safe schema handle.
import { typegres } from "typegres";
import { SqliteDriver } from "typegres/drivers/sqlite";
const db = typegres();
db.connect(SqliteDriver.create("dev.db"));
class Users extends db.Table("users") { … }
Synchronous by design: table classes are declared at module scope
against db, so making this async would force top-level await through
every module that defines a table. Backends arrive later via
db.connect(driver), with the driver imported from typegres/drivers/*
— an explicit import keeps optional peers out of bundles that don't use
them, and keeps connect synchronous for every driver but PGlite.
No arguments: the driver is the source of truth for the dialect, so the
backend is named exactly once, where the driver is built.
The entry point: a synchronous, module-load-safe schema handle.
import { typegres } from "typegres"; import { SqliteDriver } from "typegres/drivers/sqlite";
const db = typegres(); db.connect(SqliteDriver.create("dev.db"));
class Users extends db.Table("users") { … }
Synchronous by design: table classes are declared at module scope against
db, so making this async would force top-level await through every module that defines a table. Backends arrive later viadb.connect(driver), with the driver imported fromtypegres/drivers/*— an explicit import keeps optional peers out of bundles that don't use them, and keepsconnectsynchronous for every driver but PGlite.No arguments: the driver is the source of truth for the dialect, so the backend is named exactly once, where the driver is built.