猫鼬添加到父数组

问题描述

我有以下猫鼬模型 -

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)