【发布时间】:2021-07-08 13:28:59
【问题描述】:
mongoose.Types.ObjectId 工作正常,但我想使用用户文档类型更好地键入它,所以如果我填充它,它将推断出正确的类型,如profile.user.toObject({getters:true})。我看到使用UserDocument['id'] 的文章,但它会返回any。有没有合适的方法来输入这个?
interface IProfile {
user: // <- what type to put here (reference to User model)
bio: string
jobTitle: string
}
【问题讨论】:
标签: node.js typescript mongoose