You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
First off, great project - I'm really grateful for all the work you've put in on this.
The issue I'm running into with this module is when it's run within a nest monorepo the glob patterns for entity discovery does not work (for js or ts files). This appears to be a known issue also faced with TypeORM where they have added an autoLoadEntities prop in order to resolve it.
Not importing entities in manually results in a No entities were discovered error on startup.
I can (and am presently) importing files manually but this seems a bit unintuitive given that now I have to expose these from scoped libraries within the larger nest monorepo.
Install and configure @mikro-orm/nestjs as a library module
Configure an entity or two and use the glob patter in the Mikro ORM config
Run the application
Expected behavior
All entities should be discovered based on their glob and load within Mikro ORM.
Additional context
I'd be happy to do this another way if I can scope a Mikro ORM instance per library module if that's better but I'm unsure if Mikro ORM sets itself up globally and wouldn't allow this.
Versions
Dependency
Version
node
12.x
@nestjs/core
7.0.0
@mikro-orm/core
4.0.3
@mikro-orm/nestjs
4.0.0
The text was updated successfully, but these errors were encountered:
Yeah that's sounds right (first 48 hours into nest/mikro-orm). However, I wasn't sure how TypeORM was able to do this and wondered if I was missing something here. I might go through the docs again to see if there's a way I can register entities locally (in their seperate module scopes) before they are instantiated in root.
Looking at the autoLoadEntities, sure we can do the same here, it's just not supported currently.
edit: there is one issue tho - in MikroORM it is required to discover also the base entities, but you cannot use those in forFeature. so you will still need to provide list of base entities in the forRoot, rest can be autoloaded.
edit2: this also won't work for CLI, you will still need full CLI config including all the entities (but for CLI you can use globs, as there won't be any webpack used).
B4nan
changed the title
MikroOrmModule.forRoot entities glob patterns unworkable in nestjs monorepo
Add support for autoLoadEntitiesSep 23, 2020
Describe the bug
First off, great project - I'm really grateful for all the work you've put in on this.
The issue I'm running into with this module is when it's run within a nest monorepo the glob patterns for entity discovery does not work (for
js
orts
files). This appears to be a known issue also faced with TypeORM where they have added anautoLoadEntities
prop in order to resolve it.Not importing entities in manually results in a
No entities were discovered
error on startup.I can (and am presently) importing files manually but this seems a bit unintuitive given that now I have to expose these from scoped libraries within the larger nest monorepo.
To Reproduce
Steps to reproduce the behavior:
@mikro-orm/nestjs
as a library moduleExpected behavior
All entities should be discovered based on their glob and load within Mikro ORM.
Additional context
I'd be happy to do this another way if I can scope a Mikro ORM instance per library module if that's better but I'm unsure if Mikro ORM sets itself up globally and wouldn't allow this.
Versions
The text was updated successfully, but these errors were encountered: