Why MikroORM?
A modern ORM that gets out of your way and lets you focus on your domain
Unit of Work & Identity Map
Automatic change tracking and batched queries. All changes are wrapped in implicit transactions when you call em.flush().
Fully Type-Safe
Type-safe queries, populate hints, and entity operations. Even string-based filters and relations are validated at compile time.
Multiple Entity Definition Styles
Choose your style: defineEntity with full type inference, decorators, or EntitySchema. No lock-in to a single approach.
Filters & Soft Delete
Global and entity-level query filters for multi-tenancy, soft deletes, and more. Applied automatically to every query.
SQL & NoSQL
First-class support for MongoDB, PostgreSQL, MySQL, MariaDB, SQLite, libSQL, MS SQL Server, and more.
Schema Management
Prototype with SchemaGenerator, version with Migrations, or introspect existing databases with EntityGenerator.
Smart Populate & Loading
Type-checked populate hints with auto-joined loading strategies. Control exactly what gets loaded and how.
Events & Lifecycle
Powerful event system with entity lifecycle hooks, onFlush events, and metadata-aware QueryBuilder.
Seeding & Factories
Seed your database with realistic test data using entity factories. Define reusable blueprints and generate data for development and testing.
First-Class Kysely Integration
Use Kysely's type-safe SQL query builder directly with your MikroORM entities. Full autocompletion for table and column names.
Unit of Work & Identity Map
Automatic change tracking and batched queries. All changes are wrapped in implicit transactions when you call em.flush().
Fully Type-Safe
Type-safe queries, populate hints, and entity operations. Even string-based filters and relations are validated at compile time.
Multiple Entity Definition Styles
Choose your style: defineEntity with full type inference, decorators, or EntitySchema. No lock-in to a single approach.
Filters & Soft Delete
Global and entity-level query filters for multi-tenancy, soft deletes, and more. Applied automatically to every query.
SQL & NoSQL
First-class support for MongoDB, PostgreSQL, MySQL, MariaDB, SQLite, libSQL, MS SQL Server, and more.
Schema Management
Prototype with SchemaGenerator, version with Migrations, or introspect existing databases with EntityGenerator.
Smart Populate & Loading
Type-checked populate hints with auto-joined loading strategies. Control exactly what gets loaded and how.
Events & Lifecycle
Powerful event system with entity lifecycle hooks, onFlush events, and metadata-aware QueryBuilder.
Seeding & Factories
Seed your database with realistic test data using entity factories. Define reusable blueprints and generate data for development and testing.
First-Class Kysely Integration
Use Kysely's type-safe SQL query builder directly with your MikroORM entities. Full autocompletion for table and column names.
Unit of Work & Identity Map
Automatic change tracking and batched queries. All changes are wrapped in implicit transactions when you call em.flush().
Fully Type-Safe
Type-safe queries, populate hints, and entity operations. Even string-based filters and relations are validated at compile time.
Multiple Entity Definition Styles
Choose your style: defineEntity with full type inference, decorators, or EntitySchema. No lock-in to a single approach.
Filters & Soft Delete
Global and entity-level query filters for multi-tenancy, soft deletes, and more. Applied automatically to every query.
SQL & NoSQL
First-class support for MongoDB, PostgreSQL, MySQL, MariaDB, SQLite, libSQL, MS SQL Server, and more.
Schema Management
Prototype with SchemaGenerator, version with Migrations, or introspect existing databases with EntityGenerator.
Smart Populate & Loading
Type-checked populate hints with auto-joined loading strategies. Control exactly what gets loaded and how.
Events & Lifecycle
Powerful event system with entity lifecycle hooks, onFlush events, and metadata-aware QueryBuilder.
Seeding & Factories
Seed your database with realistic test data using entity factories. Define reusable blueprints and generate data for development and testing.
First-Class Kysely Integration
Use Kysely's type-safe SQL query builder directly with your MikroORM entities. Full autocompletion for table and column names.
Supported Databases
One API, multiple database backends
Define, Query, Done
Define entities your way, query with a clean type-safe API
import { defineEntity, InferEntity, p } from '@mikro-orm/core';
export const Book = defineEntity({
name: 'Book',
properties: {
id: p.number().primary(),
title: p.string(),
author: () => p.manyToOne(Author).ref(),
tags: () => p.manyToMany(Tag),
},
});
export type IBook = InferEntity<typeof Book>;
// fully type-safe queries
const books = await em.find(Book, {
author: { name: 'Tolkien' },
}, {
populate: ['author.profile'], // type-checked!
orderBy: { title: 'asc' },
});
// all changes are tracked automatically
books[0].title = 'Updated Title';
em.remove(books[1]);
// single flush = one transaction, batched queries
await em.flush();