I create a custom decorator for spawning
It is necessary to pass the mongoose model to the decorator
Provider
export const dbModelsProviders: FactoryProvider[] = [
{
provide: Db.USER_MODEL,
useFactory: (connection: Connection): Model<IUser> => connection.model('User', userSchema),
inject: [Db.DATABASE_CONNECTION]
}
];
It is necessary to pass this provider through the parameter or in any other way to another decorator
@Crud({
name: 'Test',
defaultDto: TestDto,
defaultResponseDto: TestDto,
model: <--
})
@Controller()
export class AppController {}