标签: mongoose
//比较密码
userSchema.methods.comparePassword = async function(password: string ): Promise<boolean> { return await bcrypt.compare(password, this.password); }
并且您调用的函数密码是一个字符串。
const ismatch = await user.comparePassword(password);