mongoose - 填充对象数组数组内的字段
问题描述
我的模型如下所示:
const gallerySchema = new Schema({
pictures: [[{
title: String,
file: {
type: Schema.ObjectId,
ref: 'asset',
}
}]],
createdAt: Date
});
我想填充该file
字段。
我试过这个
Gallery
.find({})
.populate({'path': 'pictures.file'})
这没有用。
解决方案
推荐阅读
- ruby - 在 rspec 自定义匹配器中重用失败消息
- javascript - 如何在 ReactJS 的 JS 文件中访问组件外的 DOM 元素
- elasticsearch - 如何通过 td-agent 将 haproxy 日志发送到 fluentd?
- django - 我无法在 NFS 中写入文件名中有一些中文字符的文件
- c# - 如何停止对我的查询字符串进行 Refit 编码?
- reactjs - 当 redux 存储发生更改时,组件不会重新渲染
- c++ - 如何捕获为 lamda 表达式生成的函子的地址?
- apache-spark - 如何在条件语句中停止 Spark 解析 UDF 列
- django - Django授予外键对象权限
- angular - 在视图中使用简单的 get 方法成本高吗?