nestjs-mongoose-crud icon indicating copy to clipboard operation
nestjs-mongoose-crud copied to clipboard

依赖注入Model到constructor编译失败

Open Jiayg opened this issue 4 years ago • 1 comments

@Crud({ model: User }) @Controller('users') @ApiTags('User') export class UsersController { constructor(@InjectModel(User) private readonly model) { } }

[Nest] 7524 - 2021/01/10 下午3:09:59 [ExceptionHandler] Nest can't resolve dependencies of the UsersController (?). Please make sure that the argument UserModel at index [0] is available in the UsersModule context.

Potential solutions:

  • If UserModel is a provider, is it part of the current UsersModule?
  • If UserModel is exported from a separate @Module, is that module imported within UsersModule? @Module({ imports: [ /* the Module containing UserModel */ ] })

Jiayg avatar Jan 10 '21 07:01 Jiayg

我也遇到了 请在admin下app.module.ts中导入DbModule import { DbModule } from '@libs/db'; @Module({ imports: [DbModule,

lichcc avatar Mar 18 '21 03:03 lichcc