У меня есть вложенная подсхема в виде массива, в этом массиве подсхем я делаю ссылку на идентификатор объекта типа Image (см. Схему изображения).что я хочу, чтобы заполнить этот идентификатор объекта данными самого изображения.возобновить желание заполнить поле в документе схемы.Я перепробовал много решений, но безуспешно, есть идеи, как этого добиться?Спасибо
У меня есть 3 схемы, подобные следующим:
const deviceSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
name: {
type: String,
required: true,
},
os: {
type: String,
required: true,
},
},
images:[assignedImagesSchema]
});
const assignedImagesSchema = new mongoose.Schema({
id: {type: mongoose.Schema.Types.ObjectId, ref:"Image"},
isVisible: {
type: Boolean,
default: true
},
visibleFor: {
type: Number,
default: 0
},
orderIndex: {
type: Number,
}
});
const imageSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
url:{
type: String,
required: true,
},
orientation: {
type: String,
required: true,
},
devices: [{type: mongoose.Schema.Types.ObjectId, ref:'Device' }]