(caller: { orm?: MikroORM; em?: EntityManager }, context: unknown)
| 21 | ) => MaybePromise<MikroORM | EntityManager | EntityRepository<any> | { getEntityManager(): EntityManager }>); |
| 22 | |
| 23 | function getEntityManager(caller: { orm?: MikroORM; em?: EntityManager }, context: unknown): EntityManager | undefined { |
| 24 | if (context instanceof EntityManager) { |
| 25 | return context; |
| 26 | } |
| 27 | |
| 28 | if (context instanceof EntityRepository) { |
| 29 | return context.getEntityManager(); |
| 30 | } |
| 31 | |
| 32 | if (context instanceof MikroORM) { |
| 33 | return context.em; |
| 34 | } |
| 35 | |
| 36 | if (caller.em instanceof EntityManager) { |
| 37 | return caller.em; |
| 38 | } |
| 39 | |
| 40 | if (caller.orm instanceof MikroORM) { |
| 41 | return caller.orm.em; |
| 42 | } |
| 43 | |
| 44 | return undefined; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Find `EntityManager` in provided context, or else in instance's `orm` or `em` properties. |
no test coverage detected