MikroORM

TypeScript ORM for Node.js built on Data Mapper, Unit of Work, and Identity Map patterns.

Library
npm
v7.1.15
9,203stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
90/100Excellent
Development Activity100
Maintenance96
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture90
Code Quality88
Innovation78
Learning Curve75

@mikro-orm/core is the engine package of MikroORM, a TypeScript object-relational mapper heavily inspired by Doctrine and Hibernate. It provides the EntityManager, metadata discovery system, unit of work with automatic change-set computation, and identity map that together drive transactional persistence across MongoDB, MySQL, MariaDB, PostgreSQL, SQLite, libSQL, MS SQL Server, and Oracle.

Unlike ORMs that mix persistence concerns directly into entity classes, MikroORM keeps entities as plain data holders and routes all reads and writes through the EntityManager, so change tracking and flush-time SQL generation stay centralized and testable. Entities can be defined with the newer defineEntity schema builder, decorators, or EntitySchema, and every database driver (installed as a separate @mikro-orm/* package) plugs into this shared core.

The package ships a type-safe QueryBuilder, cascading persist/remove through relations, global and scoped filters, schema generation and migrations, seeding, and an entity generator for reverse-engineering existing schemas from a database.

What You Get

  • EntityManager with automatic change-set computation and transactional flush
  • Identity Map so repeated loads of the same row return the same in-memory instance
  • defineEntity, decorator, and EntitySchema APIs for declaring entities without committing to one style
  • Type-safe QueryBuilder for building SQL queries with full TypeScript inference
  • Schema Generator and Migrations for evolving database structure alongside entity changes
  • Global and scoped Filters, Cascading, Embeddables, and custom type support

Common Use Cases

  • Building a Node.js/TypeScript backend that needs an ORM instead of hand-written SQL
  • Sharing one data-access layer across multiple database engines via driver packages
  • Migrating an existing Doctrine (PHP) or Hibernate (Java) team’s mental model to a Node.js stack
  • Generating and running schema migrations as entities evolve
  • Reverse-engineering entity classes from an existing database with the entity generator

Under The Hood

Architecture The package centers on a Data Mapper split between EntityManager.ts (the ~3,300-line orchestration layer) and the entity classes themselves, which stay free of persistence methods. Writes flow through unit-of-work/UnitOfWork.ts, which computes ordered change sets (ChangeSetComputer.ts, CommitOrderCalculator.ts) and persists them (ChangeSetPersister.ts) inside a transaction on flush, while entity/EntityFactory.ts and metadata/MetadataDiscovery.ts handle entity hydration and metadata resolution. Database-specific behavior is isolated behind drivers/IDatabaseDriver.ts, letting @mikro-orm/postgresql, @mikro-orm/mongodb, and similar packages plug in without touching core orchestration — changing the abstraction would ripple through every driver package in the monorepo.

Tech Stack Written entirely in TypeScript (99.7% of the codebase) as an ESM-only package targeting Node.js 22.17+. The core has no runtime dependencies of its own beyond an optional peer dependency on dataloader; all database connectivity is deferred to sibling packages in the same Lerna-managed monorepo (packages/postgresql, packages/mongodb, etc.), keeping the core package’s own dependency surface minimal.

Code Quality Tests run under Vitest across dozens of top-level *.test.ts files plus dedicated suites per feature area, exercising real database backends (SQLite, MySQL, Postgres, MongoDB) via Docker Compose in CI rather than mocks alone. Errors are modeled as a typed hierarchy (ValidationError and subclasses in errors.ts) with factory methods for specific failure conditions instead of generic thrown strings. The monorepo enforces oxlint and a dedicated formatter config, and GitHub Actions runs a full test matrix plus CodeQL scanning on every change.

What Makes It Unique Most Node.js ORMs couple entity classes to the database or bake in a single database engine; MikroORM’s core/driver split lets one persistence and change-tracking engine run identically across eight database engines, mirroring patterns Doctrine and Hibernate established but is comparatively rare for TypeScript-first tooling. The optional defineEntity schema-first API gives a way to declare entities without decorators or class boilerplate while retaining the same Identity Map and Unit of Work guarantees as the decorator-based flow.

Used by 7 apps in this directory

Go
79%
Apache 2.0

Dolt

Databases · Data Engineering · Developer Tools

24,372

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
91
Repo Health
9
Technical
65
Dependency
Built with
Go79%
Shell20%
Updated yesterday
Go
79%
Apache 2.0

Dolt

Databases · Data Engineering · Developer Tools

24,372

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
91
Repo Health
9
Technical
65
Dependency
Built with
Go79%
Shell20%
Updated yesterday
TypeScript
86%
MIT

medusa

Ecommerce

36,163

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
93
Repo Health
87
Technical
63
Dependency
Built with
TypeScript86%
JavaScript14%
Updated 2 days ago
TypeScript
86%
MIT

medusa

Ecommerce

36,163

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
93
Repo Health
87
Technical
63
Dependency
Built with
TypeScript86%
JavaScript14%
Updated 2 days ago
TypeScript
86%
MIT

medusa

Ecommerce

36,163

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
93
Repo Health
87
Technical
63
Dependency
Built with
TypeScript86%
JavaScript14%
Updated 2 days ago
TypeScript
86%
MIT

medusa

Ecommerce

36,163

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
93
Repo Health
87
Technical
63
Dependency
Built with
TypeScript86%
JavaScript14%
Updated 2 days ago
TypeScript
86%
MIT

medusa

Ecommerce

36,163

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
93
Repo Health
87
Technical
63
Dependency
Built with
TypeScript86%
JavaScript14%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search