Open fotAlat opened 2 years ago
Would it be a good idea to hack it like this?
type IUser = InferSchemaType<typeof userSchema>;
const User = mongoose.model('User', userSchema);
const UserTC = composeMongoose(User as unknown as Model<Document<IUser>>, {});
I have a similar issue when attempting to use a model from typegoose when the class/interface (eg. User) doesn't extend document.
const userModel = getModelForClass(User) const UserModelTC = composeMongoose(userModel)
Argument of type 'ReturnModelType<typeof User, BeAnObject>' is not assignable to parameter of type 'Model<Document<any, any, any>, {}, {}, {}, Document<unknown, {}, Document<any, any, any>> & Document<any, any, any> & { _id: ObjectId; }, any>'.
I was interested in using the library because i found it very handy in terms of translating Mongoose Schemas to GraphQLObjects. I was blown away by how good it works but i noticed something. In models that we use Typescript interfaces it complains if I do not use the Extends Documents in the interface.
Is there any reason why we should use the extends Document when the mongoose Documentation recommends against that?
https://mongoosejs.com/docs/typescript.html