Skip to content

Commit 3656eaf

Browse files
committed
fix: reuse single MikroORM instance
1 parent 87f7d8c commit 3656eaf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/mikro-orm.providers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ export function createMikroOrmProvider(
99
contextName?: string,
1010
type: Type = MikroORM,
1111
): Provider {
12+
if (!contextName && type !== MikroORM) {
13+
return {
14+
provide: type,
15+
useFactory: orm => orm, // just a simple alias
16+
inject: [MikroORM], // depend on the ORM from core package
17+
};
18+
}
19+
1220
return {
1321
provide: contextName ? getMikroORMToken(contextName) : type,
1422
useFactory: async (options?: MikroOrmModuleOptions) => {

0 commit comments

Comments
 (0)