首页 > 解决方案 > 填充对象数组数组内的字段

问题描述

我的模型如下所示:

const gallerySchema = new Schema({
  pictures: [[{
    title: String,
    file: {
      type: Schema.ObjectId,
      ref: 'asset',
    }
  }]],
  createdAt: Date
});

我想填充该file字段。

我试过这个

Gallery
.find({})
.populate({'path': 'pictures.file'})

这没有用。

标签: mongoosemongoose-populate

解决方案


推荐阅读