Adapters
The adapters share one model syntax and one client API, so switching databases needs no regeneration; what differs is the driver, the connection model, and a few type rules. Each pins driver options and session settings and maps driver errors to the same error codes; physical type mappings are in Type Mapping. createClient picks the adapter from the connection URL scheme, and the driver loads and connects on the first database operation, so creating a client neither loads a driver nor touches the database.
Adapter Matrix
| Adapter | Connection model |
|---|---|
| MySQL / MariaDB | Pool, one connection per root request |
| PostgreSQL | Pool, one connection per root request |
Each root request's nested query tree or write graph stays on that connection; a shared connection alone does not guarantee a shared snapshot — see Transactions. Versions, drivers, and capabilities are in the Capability Matrix.
Initialization and Upgrades
Adapters do not create tables. Use tsorm push while prototyping and versioned migrations for schema creation and upgrades.
Choosing an Adapter
- MySQL / MariaDB: MySQL 8.0.16+ or MariaDB 10.6+ with InnoDB. DDL commits implicitly, so a failed migration needs manual inspection and cleanup.
- PostgreSQL: PostgreSQL 14+, with a
schemaquery parameter, nativeBOOLEANandIDENTITYtypes.
Next Steps
- MySQL / MariaDB, PostgreSQL: connection options, type details, initialization, writes, transactions, and error mapping for each adapter
- Capability Matrix: what each database supports, side by side
- Versioned Migrations: diffing a schema and applying migrations in order