Bird
0
0

What is the primary effect of calling TypeOrmModule.forRoot() with configuration in a NestJS app module?

medium📝 component behavior Q4 of 15
NestJS - Database with TypeORM
What is the primary effect of calling TypeOrmModule.forRoot() with configuration in a NestJS app module?
AIt establishes a global database connection and registers entities for the app
BIt only registers repositories without creating a connection
CIt configures middleware for HTTP requests
DIt disables automatic synchronization of entities
Step-by-Step Solution
Solution:
  1. Step 1: Understand forRoot purpose

    forRoot sets up the database connection globally for the app.
  2. Step 2: Recognize entity registration

    Entities passed in configuration are registered for ORM mapping.
  3. Final Answer:

    It establishes a global database connection and registers entities for the app -> Option A
  4. Quick Check:

    forRoot creates connection and registers entities [OK]
Quick Trick: forRoot sets up global DB connection and entities [OK]
Common Mistakes:
  • Thinking forRoot only registers repositories
  • Confusing forRoot with middleware setup
  • Assuming it disables synchronization

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes