I have to save a user in user model
const userDoc: Document = new User(user);
const userData: UserModel = await userDoc.save();
the below warning is coming when i specify type on userdata
Type 'Document' is not assignable to type 'UserModel'. Type 'Document' is not assignable to type '{ email: string; password: String; phone: Number; verificationToken: String; emailVerified: Boole...'. Property 'email' is missing in type 'Document'
If you look at the declaration of save
, it returns a promise for the same type as the object on which it is called:
save(options?: SaveOptions, fn?: (err: any, product: this) => void): Promise<this>;
Thus, declaring userDoc
as type User
or UserModel
or just removing the type annotation on userDoc
should help.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments