Introduction
TSORM (@ofis/tsorm) is a TypeScript ORM: define models in a schema.orm file, generate a type-safe client, connect through an adapter.
How It Works
- Define and generate: describe fields, relations, and constraints in
schema.orm— the single source of truth — then runtsorm generatefor a database-independent client. - Choose a database: pass a
mysql://(ormariadb://) orpostgresql://URL; switching needs no regeneration. - Manage structure: versioned migrations in real projects,
pushwhile prototyping.
Supported Scope
| Item | Minimum | Recommended |
|---|---|---|
| Node.js | 20.0 | 26 LTS |
| MySQL | 8.0.16, via the mariadb client | 8.4 LTS |
| MariaDB | 10.6, via the mariadb client | 11.4 LTS |
| PostgreSQL | 14, via the pg client | 16 |
Requires Node.js 20.0+, the floor of the bundled mariadb driver; adapters validate minimum server versions. Test selection: Development & Validation. Per-database features: capability matrix.
Install
npm install @ofis/tsormGenerate a client and import createClient(options) from ./generated/client.ts; the adapter is chosen from the connection URL scheme — the root @ofis/tsorm entry (internalCreateClient) is for advanced use only, and adapters are internal modules selected by URL, not package entries. Schema and migration APIs come from @ofis/tsorm/schema and @ofis/tsorm/migrations. Run tsorm via a package script or npx tsorm.
Versioning
0.x releases
TSORM is 0.x: a minor bump (for example 0.14 to 0.15) may contain breaking changes. Pin the version and review changes before upgrading.
Next Steps
- Run your first query with the getting started guide; full DSL syntax in the schema reference.