Skip to content

Commit

Permalink
fix: reuse single MikroORM instance
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed May 19, 2024
1 parent 87f7d8c commit 3656eaf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/mikro-orm.providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ export function createMikroOrmProvider(
contextName?: string,
type: Type = MikroORM,
): Provider {
if (!contextName && type !== MikroORM) {
return {
provide: type,
useFactory: orm => orm, // just a simple alias
inject: [MikroORM], // depend on the ORM from core package
};
}

return {
provide: contextName ? getMikroORMToken(contextName) : type,
useFactory: async (options?: MikroOrmModuleOptions) => {
Expand Down

0 comments on commit 3656eaf

Please sign in to comment.