NestJS · Junior · Question 74 of 75

Why use TypeOrmModule.forRootAsync({ useFactory, inject: [ConfigService] }) instead of forRoot({...})?

Explanation

Async configuration is a common pattern for dynamic modules: the factory runs after its dependencies are ready.

Further reading

Problem with a question

NestJS · Junior · question 74

Test yourself

Take the NestJS · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz