Skip to content
Advertisement

Nest can’t resolve dependencies of the UserModel (?)

When I try to use MongooseModel on Users I am getting the following error

Nest can’t resolve dependencies of the UserModel (?). Please make sure that the argument DatabaseConnection at index [0] is available in the MongooseModule context.

/src/database/database.module.ts

JavaScript

/src/database/database.provider.ts

JavaScript

/src/app.module.ts

JavaScript

/src/auth/auth.module.ts

JavaScript

/src/users/user.module.ts

JavaScript

Advertisement

Answer

Instead of configuring mongoose statically in your database.provider.ts, you should use the MongooseModule.forRootAsync import:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement