nestjs-typegoose
nestjs-typegoose copied to clipboard
Typegoose library hook errors.....Generic type
Hello am trying to reduce the number of classes and interfaces that are required by mongoose so I am trying typegoose to solve this....
My dto
import { ApiProperty } from '@nestjs/swagger'; import { IsNotEmpty } from 'class-validator'; import { prop } from '@typegoose/typegoose'; export class zcharm {
@IsNotEmpty()
@ApiProperty({example: 'c4q-435', description: 'Quality environment centerlink'})
@prop({ required: true })
environment: string;
@IsNotEmpty()
@ApiProperty({example: 'TDK1234566', description: 'SAP Transport'})
@prop({ required: true })
transportName: string;
@IsNotEmpty()
@ApiProperty({example: 'AR#', description: 'SAP Userid'})
@prop({ required: true })
userid: string;
}
My service
import { Injectable } from '@nestjs/common'; import { zcharm } from './dto/create-zcharm.dto'; import { UpdateZcharmDto } from './dto/update-zcharm.dto'; import { InjectModel } from 'nestjs-typegoose'; import { ReturnModelType } from '@typegoose/typegoose';
@Injectable()
export class ZcharmService {
constructor (
@InjectModel(zcharm) private readonly model: ReturnModelType
my module
import { Module } from '@nestjs/common'; import { ZcharmService } from './zcharm.service'; import { ZcharmController } from './zcharm.controller'; import { TypegooseModule } from "nestjs-typegoose"; import { zcharm } from './dto/create-zcharm.dto'; @Module({ imports: [ TypegooseModule.forFeature([zcharm])], controllers: [ZcharmController], providers: [ZcharmService] }) export class ZcharmModule {}
The error I get is node_modules/@typegoose/typegoose/lib/hooks.d.ts:8:41 - error TS2707: Generic type 'Query<ResultType, DocType, THelpers>' requires between 2 and 3 type arguments.
not sure where to look why this is causing this error I followed the documentation in the example also want to know will swagger still work now that we have @prop and @ApiPropetry as well
Hello, could you solve it? I have the same error
Hello, could you solve it? I have the same error
Hello sorry about the late reply I could not solve it using typegoose but solved it using mongoose it self I was trying to avoid duplication schema document and class. Now I use schema factory for class to define the schema and export type like classdocument = class & Document
Tip Document imported from nestjs/ mongoose
Now I have all three types in one class
On Fri, 2 Jul 2021, 18:09 水痕, @.***> wrote:
Hello, could you solve it? I have the same error
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kpfromer/nestjs-typegoose/issues/420#issuecomment-872806362, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKRSYGNWSDDE5S5JPKZBR3TVVXZXANCNFSM45MEL4IQ .