A lightweight, SQL-friendly TypeScript ORM for PostgreSQL, MySQL, and SQLite (v1.2.7, released monthly). Designed for production systems requiring predictable SQL, explicit performance control, and operational safety (replication-lag-aware reader/writer routing, automatic N+1 prevention, configurable hard limits). Uses Active Record pattern with symbol-based columns, tuple conditions, and raw SQL escape hatches. Unlike Prisma or TypeORM, it prioritizes SQL visibility and explicit transaction boundaries over magic. Requires Node >=18 and peer dependencies for each database driver.
npm install litedbmodelNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to define a model, connect to PostgreSQL, create a user, find by email, and execute raw SQL.
Pass a transaction (tx) from db.transaction() or use db.query() for reader-only reads.
Wrap reads in db.transaction() or use db.query() for explicit reader access.
Use Model.columns.columnName (symbol) instead of 'column_name' string.
Use Model.find({ include: ['posts'] }) to eagerly load relations and avoid per-relation queries.db.transaction(async (tx) => { ... })Use Model.columns.columnName (e.g., User.columns.name) instead of User.column.
Install pg (npm install pg) and create a pool before calling Model.connect().