mikro-orm is a free, open source databases project written in TypeScript and released under MIT. It has 9,231 GitHub stars, 673 forks and 20 open issues, and was last pushed 2 hours ago. On this registry it ranks #88 of 143 tracked projects in Databases, with 5 head-to-head comparisons available.

What is mikro-orm?

MikroORM is a TypeScript ORM for Node.js built on the Data Mapper, Unit of Work and Identity Map patterns, aimed at TypeScript teams that want typed, entity-based persistence across MongoDB, MySQL, MariaDB, MS SQL Server, PostgreSQL, Oracle and SQLite/libSQL databases.

What it is

MikroORM is an MIT-licensed TypeScript ORM published on npm under @mikro-orm/core with separate driver packages for each supported database. It sits in the Node.js ecosystem and follows the Data Mapper, Unit of Work and Identity Map patterns, which means entities are plain classes and persistence is coordinated by an entity manager rather than by the entities themselves. The project is heavily inspired by Doctrine and Hibernate, and it is catalogued under Infrastructure & Operations / Databases. It is actively maintained, with 9,231 stars, 673 forks and 20 open issues, and its most recent push is dated September 2026.

The concrete problem it solves is the persistence glue that Node.js applications otherwise accumulate by hand: tracked changes, transaction boundaries, identity handling and query construction. Instead of writing bespoke repository layers and manual change tracking, developers create entities, mutate them, and call orm.em.flush(), which persists all tracked changes in a single transaction. The Identity Map keeps one in-memory instance per database row, and RequestContext isolates that map per request so concurrent web requests do not share entity state. Type-safe queries come from orm.em.createQueryBuilder() and getResult(), or from finder calls using populate and orderBy.

Key capabilities

  • Entity definition through defineEntity with property helpers such as p.integer().primary(), p.string(), p.oneToMany(Book).mappedBy('author') and p.manyToOne(Author).inversedBy('books'), combined with setClass.
  • Alternative entity definitions using decorators or the EntitySchema low-level API.
  • Unit of Work semantics where a single await orm.em.flush() persists all tracked changes in one transaction.
  • Identity Map support with RequestContext.create(orm.em, next) as Express middleware, isolating the identity map per request.
  • Per-database driver packages: @mikro-orm/postgresql, @mikro-orm/pglite, @mikro-orm/mysql, @mikro-orm/mariadb, @mikro-orm/sqlite, @mikro-orm/libsql, @mikro-orm/sql-js, @mikro-orm/mongodb, @mikro-orm/mssql and @mikro-orm/oracledb.
  • Support for embedded and WASM-backed databases, including PGlite (embedded PostgreSQL in WASM), sql.js (in-memory SQLite in WASM) and libSQL/Turso.
  • Companion tooling in @mikro-orm/cli, @mikro-orm/migrations and @mikro-orm/entity-generator.

Who uses it and how

  • Node.js backend teams that want entity-based persistence and compile-time query safety rather than raw SQL strings.
  • Applications that must target several engines at once, spanning PostgreSQL (including CockroachDB and PGlite), MySQL, MariaDB, MSSQL, Oracle, MongoDB and SQLite dialects.
  • Express and similar web applications that need per-request Identity Map isolation through RequestContext.create(orm.em, next).
  • Teams deploying against libSQL/Turso or embedded PostgreSQL, where the WASM-capable drivers replace a separately hosted database server.
  • Projects that need versioned schema migrations or want to reverse-engineer an existing schema into entities via the entity generator.

Getting started

Install the driver package for the database in use, for example npm install @mikro-orm/postgresql, and install @mikro-orm/core explicitly when using @mikro-orm/cli, @mikro-orm/migrations or @mikro-orm/entity-generator. The quick start guide at https://mikro-orm.io/docs/quick-start covers initialisation with MikroORM.init.

How it compares

The facts provide no list of paid products that MikroORM replaces, so no licence or cost comparison is made here. Within this registry it stands alongside the other Node.js ORMs rather than displacing a commercial product, and its stated lineage is Doctrine and Hibernate, the PHP and Java persistence frameworks that shaped its Data Mapper, Unit of Work and Identity Map design.

When to use it — and when not to

Adopting MikroORM means running and operating the actual database yourself, since the project supplies a library and its documentation rather than a hosted service, and no administration interface is mentioned. The migration, CLI and entity-generation capabilities live outside the driver packages, so those require the additional explicit @mikro-orm/core installation. Teams outside the TypeScript and Node.js ecosystem, or those whose database is not among the supported engines, should look elsewhere.

project readme (upstream, from github) — read inline

MikroORM

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL (including CockroachDB and PGlite), SQLite (including libSQL), MSSQL and Oracle databases.

Heavily inspired by Doctrine and Hibernate.

NPM version NPM dev version Chat on discord Downloads Coverage Status Build Status

Quick Start

Install a driver package for your database:

npm install @mikro-orm/postgresql   # PostgreSQL
npm install @mikro-orm/pglite       # PGlite (embedded PostgreSQL in WASM)
npm install @mikro-orm/mysql        # MySQL
npm install @mikro-orm/mariadb      # MariaDB
npm install @mikro-orm/sqlite       # SQLite
npm install @mikro-orm/libsql       # libSQL / Turso
npm install @mikro-orm/sql-js       # sql.js (in-memory SQLite in WASM)
npm install @mikro-orm/mongodb      # MongoDB
npm install @mikro-orm/mssql        # MS SQL Server
npm install @mikro-orm/oracledb     # Oracle

If you use additional packages like @mikro-orm/cli, @mikro-orm/migrations, or @mikro-orm/entity-generator, install @mikro-orm/core explicitly as well. See the quick start guide for details.

Define Entities

The recommended way to define entities is using defineEntity with setClass:

import { defineEntity, p, MikroORM } from '@mikro-orm/postgresql';

const AuthorSchema = defineEntity({
  name: 'Author',
  properties: {
    id: p.integer().primary(),
    name: p.string(),
    email: p.string(),
    born: p.datetime().nullable(),
    books: () => p.oneToMany(Book).mappedBy('author'),
  },
});

export class Author extends AuthorSchema.class {}
AuthorSchema.setClass(Author);

const BookSchema = defineEntity({
  name: 'Book',
  properties: {
    id: p.integer().primary(),
    title: p.string(),
    author: () => p.manyToOne(Author).inversedBy('books'),
  },
});

export class Book extends BookSchema.class {}
BookSchema.setClass(Book);

You can also define entities using decorators or EntitySchema. See the defining entities guide for all options.

Initialize and Use

import { MikroORM, RequestContext } from '@mikro-orm/postgresql';

const orm = await MikroORM.init({
  entities: [Author, Book],
  dbName: 'my-db',
});

// Create new entities
const author = orm.em.create(Author, {
  name: 'Jon Snow',
  email: '[email protected]',
});
const book = orm.em.create(Book, {
  title: 'My Life on The Wall',
  author,
});

// Flush persists all tracked changes in a single transaction
await orm.em.flush();

Querying

// Find with relations
const authors = await orm.em.findAll(Author, {
  populate: ['books'],
  orderBy: { name: 'asc' },
});

// Type-safe QueryBuilder
const qb = orm.em.createQueryBuilder(Author);
const result = await qb
  .select('*')
  .where({ books: { title: { $like: '%Wall%' } } })
  .getResult();

Request Context

In web applications, use RequestContext to isolate the identity map per request:

const app = express();

app.use((req, res, next) => {
  RequestContext.create(orm.em, next);
});

More info about RequestContext is described here.

Unit of Work

Unit of Work maintains a list of objects (entities) affected by a business transaction and coordinates the writing out of changes. (Martin Fowler)

When you call em.flush(), all computed changes are queried inside a database transaction. This means you can control transaction boundaries simply by making changes to your entities and calling flush() when ready.

const author = await em.findOneOrFail(Author, 1, {
  populate: ['books'],
});
author.name = 'Jon Snow II';
author.books.getItems().forEach(book => book.title += ' (2nd ed.)');
author.books.add(orm.em.create(Book, { title: 'New Book', author }));

// Flush computes change sets and executes them in a single transaction
await em.flush();

The above flush will execute:

begin;
update "author" set "name" = 'Jon Snow II' where "id" = 1;
update "book"
  set "title" = case
    when ("id" = 1) then 'My Life on The Wall (2nd ed.)'
    when ("id" = 2) then 'Another Book (2nd ed.)'
    else "title" end
  where "id" in (1, 2);
insert into "book" ("title", "author_id") values ('New Book', 1);
commit;

Core Features

Documentation

MikroORM documentation, included in this repo in the root directory, is built with Docusaurus and publicly hosted on GitHub Pages at https://mikro-orm.io.

There is also auto-generated CHANGELOG.md file based on commit messages (via semantic-release).

Example Integrations

You can find example integrations for some popular frameworks in the mikro-orm-examples repository:

TypeScript Examples

JavaScript Examples

Contributing

Contributions, issues and feature requests are welcome. Please read CONTRIBUTING.md for details on the proces

readme truncated — read the full docs on github

Frequently asked questions

Is mikro-orm free to use?

mikro-orm is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does mikro-orm do?

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, MS SQL Server, PostgreSQL and SQLite/

What is mikro-orm written in?

mikro-orm is primarily written in TypeScript. Its source is publicly available at https://github.com/mikro-orm/mikro-orm, and it has 9,231 GitHub stars.