Documentation / @zerotal/orm / index / DatabaseConfigShape
Interface: DatabaseConfigShape
Defined in: packages/orm/src/config.ts:9
Shape of the database config namespace produced by DatabaseConfig.
Consumed by DatabaseProvider to build the connection, read replicas,
pool, and auto-sync behaviour.
Properties
driver
driver:
"sqlite"|"postgres"|"mysql"
Defined in: packages/orm/src/config.ts:11
Database driver. Default: 'sqlite'
url
url:
string
Defined in: packages/orm/src/config.ts:13
Connection URL. Default: './database/db.sqlite'
replicas?
optionalreplicas?:string[]
Defined in: packages/orm/src/config.ts:28
Read-replica connection URLs.
When one or more replicas are configured, the ORM automatically routes SELECT / WITH / EXPLAIN queries to replicas (round-robin) and all mutating queries (INSERT, UPDATE, DELETE, DDL) plus transactions to the primary. No code changes are required in controllers or models.
Example
replicas: [
env('REPLICA_1_URL'),
env('REPLICA_2_URL'),
]
pool?
optionalpool?:object
Defined in: packages/orm/src/config.ts:33
Connection pool options (PostgreSQL and MySQL only). Bun.sql manages the pool automatically - these tune its behaviour.
max?
optionalmax?:number
Maximum number of connections in the pool. Default: 10
idleTimeout?
optionalidleTimeout?:number
Seconds an idle connection is kept before being closed. Default: 30
sqlite
sqlite:
object
Defined in: packages/orm/src/config.ts:40
SQLite-specific options
path
path:
string
Path to the SQLite file. Use ':memory:' for in-memory database.
synchronize?
optionalsynchronize?:boolean| {enabled:boolean;disruptive?:boolean; }
Defined in: packages/orm/src/config.ts:58
Auto-sync the schema to your models at boot (TypeORM-style). Opt-in, and hard-off in production regardless of this value.
false(default): never sync; use generated migrations.true: additive sync - create missing tables, add missing columns. Never drops.{ enabled, disruptive }: setdisruptive: trueto also DROP columns that no model declares anymore (destroys their data - local/test only).
Example
synchronize: env("APP_ENV") !== "production" // additive
synchronize: { enabled: true, disruptive: false } // explicit, additive
synchronize: { enabled: true, disruptive: true } // also drops removed columns