DEV Community

Discussion on: NestJS: Using a generic service to provide base CRUD functionality

Collapse
paularah profile image
Paul Arah • Edited on

you can extend the Document type by creating an intersection type like this export type UserDocument = User & Document;and then pass the UserDocument type when you inject in your service. This is assuming you're using the InjectModel decorator that from the nestjs/mongose module. An example of what you would pass into your user service constructor would look like this @InjectModel(User.name) private readonly userModel: Model<UserDocument>