Node.js 更新时的Mongoose将虚拟填充保存到文档
由于某些原因,mongoose没有正确更新。它正在我的Node.js 更新时的Mongoose将虚拟填充保存到文档,node.js,typescript,mongoose,nestjs,Node.js,Typescript,Mongoose,Nestjs,由于某些原因,mongoose没有正确更新。它正在我的文档中添加虚拟现实 const BlogSchema: Schema = new Schema<Blog>({ clientId: { type: Schema.Types.ObjectId } //... }) ClientSchema.virtual('client', { ref: 'clients', localField: 'clientId', foreignField: '_id',
文档中添加虚拟现实
const BlogSchema: Schema = new Schema<Blog>({
clientId: {
type: Schema.Types.ObjectId
}
//...
})
ClientSchema.virtual('client', {
ref: 'clients',
localField: 'clientId',
foreignField: '_id',
justOne: true,
});
//...
return this.clientScreeningsModel
.findById(id)
.populate('client', 'email username')
.lean(true);
它会将客户端对象也保存到我的文档中
,mongoose不知道它是虚拟的吗
提前感谢您的帮助:)由于我仍然无法找到解决方案,我将转到他们的github:)由于我仍然无法找到解决方案,我将转到他们的github:)
{
_id: 'something',
clientId: 'previousId',
client: {
email: 'foo@bar.com',
username: 'JohnDoe'
}
}