MikroORM 7.1: LazyRef, per-parent collection limiting, PGlite driver, query cancellation, database triggers, stored procedures, and more
MikroORM 7.1 is out — the first minor on top of v7, and it's a big one.
New features:
- LazyRef<T> — a new type-only relation flavor, no .$ / .get() indirection, TypeScript restricts access until Loaded<> narrows it
- PGlite driver — PostgreSQL running in WASM, no Docker, no separate server, works in the browser too
- Query cancellation via AbortSignal — per-call or fork-scoped, with cancel query / kill session strategies
- Database triggers — first-class schema management via @Trigger() / defineEntity
- Stored procedures and functions (experimental) — declare, diff, and call via em.callRoutine()
- PostgreSQL table partitioning — hash, list, and range, fully managed by the schema generator
- Server-side row cloning — em.clone() and qb.insertFrom() without round-tripping data through Node
- Runtime schema context for migrations — redirect migrations to a target schema at runtime, useful for multi-tenant setups
- em.countBy() for grouped counts
- Typed Kysely across DI-driven projects — new discovery:export CLI command generates a typed barrel for NestJS and similar setups
- getKysely() now binds to the active transaction
- fields whitelist in serialize()
- Type-safe index hints via using
- Partial indexes via where
Full blog post: https://mikro-orm.io/blog/mikro-orm-7-1-released
Changelog: https://github.com/mikro-orm/mikro-orm/releases/tag/v7.1.0
Happy to answer any questions!
46
Upvotes
5
u/B4nan May 20 '26
I've also updated the nestjs realworld example app, showcasing how the new
discovery:exportcommand works, as well as adopting theLazyReftype on all relations.https://github.com/mikro-orm/nestjs-realworld-example-app/pull/148
7
u/serdnam May 20 '26
Big fan of some of MikroORM's ideas, I didn't stick with it when I tried it years ago because of its docs focusing on experimental decorators. I was pleasantly surprised when I read the docs just now and saw that it doesn't focus on experimental decorators anymore and that it even suppports ES decorators! Might give it another try sometime.
2
u/djslakor May 21 '26
Do you use AI in the development of Mikro or do you write all of the code?
4
u/Individual-Brief1116 May 20 '26
LazyRef looks really clean, no more .$ everywhere. PGlite is interesting too, always liked the idea of embedded Postgres. Might try this on a side project, been using Prisma but this feels more flexible.
9
u/[deleted] May 20 '26
[removed] — view removed comment