Why should we call the module twice?
See original GitHub issueI have one module in my app, with the last update I should write this:
@Module({
imports: [
TypeOrmModule.forRoot({
/* Connection options goes here */,
entities: [/* Entities goes here */],
}),
TypeOrmModule.forFeature([/* Entities goes here */]),
]
})
Why? I’ve already pass my entities inside options. And now I importing the same module twice.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Calling a module multiple times causing duplicate resource ...
Generally speaking, it's the responsibility of a module to ensure that it doesn't make any assumptions that would prevent it from being ......
Read more >Terraform use case to create multiple almost identical copies ...
Creating a module is nothing special: just put any Terraform templates in a folder. What makes a module special is how you use...
Read more >What Happens When a Module Is Imported Twice?
The rules are quite simple: the same module is evaluated only once, in other words, the module-level scope is executed just once. If...
Read more >for_each to call terraform module multiple times - Terragrunt
Since each call is a separate module call, having each one share state will result in each call stepping over each other.
Read more >Modules - Configuration Language | Terraform
A module can call other modules, which lets you include the child module's resources into the configuration in a concise way. Modules can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@obedm503 yeah, I have the same thought about it. It will be great if
forRoot
method creates repositories for entities if they was provided as classes array. We can have both methods implemented. AlsoforFeature
name doesn’t explain what the function actually do. It is better to call itprovideRepositories
or smth like that.What about people who:
forRoot
in aDatabaseModule
which exports the instanciated connectionforFeature([ User ])
in aUserModule
which imports theDatabaseModule
forFeature([ Car ])
in aCarModule
which imports theDatabaseModule
Repository<User>
available in theCarModule
Repository<Car>
available in theUserModule
I don’t think that what you’re asking for would allow that design.