我有以下猫鼬模型 -
file:
{
name: string,
links: [{
views: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'view',
}]
}]
}
view:
{
link: {
type: mongoose.Schema.Types.ObjectId,
ref: 'file.links',
index: true,
}
}
当我创建视图时,它会在 view
文档中设置正确的链接,但是,视图 ID 不会添加到文件 document
中的链接数组中。
是否可以自动完成?另外,在查询 views
文档时如何填充 file
?