Skip to content

IEntityManagerSource

Defined in: packages/ddd-mikro-orm/src/interfaces/entity-manager-source.ts:19

Supplies the MikroORM EntityManager for the current operation.

AggregateRepository and MikroOrmCache read em on every operation and never keep it, so a source may return a different manager each time: the current tenant’s in a multi-tenant application, or the current request’s. A getter over the application’s own store satisfies it, and so does a plain { em } object in a single-database setup or a test.

const source: IEntityManagerSource = { em: orm.em.fork() };

readonly em: EntityManager

Defined in: packages/ddd-mikro-orm/src/interfaces/entity-manager-source.ts:20