Bird
0
0

Which is the correct way to import TypeORM module in a NestJS module?

easy📝 Syntax Q12 of 15
NestJS - Database with TypeORM
Which is the correct way to import TypeORM module in a NestJS module?
Aimports: [TypeOrmModule.forRoot()]
Bimports: [TypeOrmModule.init()]
Cimports: [TypeOrmModule.connect()]
Dimports: [TypeOrmModule.start()]
Step-by-Step Solution
Solution:
  1. Step 1: Recall the official NestJS TypeORM integration syntax

    The correct method to initialize TypeORM in NestJS is using TypeOrmModule.forRoot() inside the imports array.
  2. Step 2: Check other options for correctness

    Methods like init(), connect(), or start() do not exist in TypeOrmModule for NestJS.
  3. Final Answer:

    imports: [TypeOrmModule.forRoot()] -> Option A
  4. Quick Check:

    Use forRoot() to import TypeORM [OK]
Quick Trick: Remember: forRoot() initializes TypeORM in NestJS [OK]
Common Mistakes:
  • Using non-existent methods like init()
  • Confusing connect() with forRoot()
  • Trying to start() TypeORM module

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes