【发布时间】:2021-05-16 00:20:11
【问题描述】:
对于 MongoDB 的架构验证器,我有以下内容:{
UserSchema.path('email').validate(async function (email: string) {
const count = await User.count({ email, _id: { $ne: this._id } })
return !count
}, 'Email already exists')
我收到以下错误:
'this' implicitly has type 'any' because it does not have a type annotation.ts(2683)
User.ts(171, 35): An outer value of 'this' is shadowed by this container.
这是在我的User.ts 文件中定义的。一切都按预期工作,但这个 Typescript 错误阻止 CI 继续。有没有办法解决这个问题(没有双关语)。
【问题讨论】:
标签: mongodb typescript mongoose