NestJS · Junior · Question 45 of 75
How is TypeORM typically connected to a Nest app?
- 1By creating a connection in every service
- 2Through a global variable in
main.ts - ✓Correct answer:
TypeOrmModule.forRoot()in the root module andTypeOrmModule.forFeature([User])in feature modules to inject repositories
Explanation
In a service you then inject @InjectRepository(User) private users: Repository<User>.