TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns.
Implicit Transactions
MikroORM allows handling transactions automatically. When you call em.flush()
, all computed changes are wrapped inside a database transaction.
DRY Entities
Uses source code analysis so you do not have to repeat yourself when defining entities. Simply define correct TypeScript types and you are good to go!
Supports both SQL and NoSQL
Supports MongoDB, MySQL, MariaDB, PostgreSQL, MS SQL Server, and SQLite (including libSQL) databases, and more can be supported via custom drivers right now.
In sync with your database
Prototype schemas out of entity definitions rapidly with the SchemaGenerator, generate migration diffs out of entity definitions with the Migrator, or introspect your database with the EntityGenerator to get entity definitions out of your database schema.
Seeder
With the Seeder and seeding factories, we can generate fake data of any volume/shape and seed the database with ease.
Automatic Batching
Thanks to the UnitOfWork, all queries it fires are automatically batched. Inserts, updates, deletes - you name it!
Events
Powerful event system allows to hook into not only the entity lifecycle. Want to alter how the UnitOfWork works? Try onFlush
event!
QueryBuilder
Includes metadata-aware QueryBuilder with auto-joining support. Need more flexibility? We got you covered!
Filters
Define and control your common filters globally. Want to show only results relevant for a given tenant? Or maybe you want to automatically hide all soft-deleted entities?