Mongoose populate with array of objects containing ref
I found the answer: populate('lists.list')
works. Thanks to this question: Mongoose populate within an object?
lists: [
{
list: {
type: Schema.ObjectId,
require: true,
ref: "List"
},
allocations: [
{
type: Number,
required: true
}
]
}
],
=> Because it's an array of objects, you can do this -: Portfolio.populate('lists.list');
2.
lists: [
{
type: Schema.ObjectId,
require: true,
ref: "List"
}
]
=> Because it's an array, you just have to do this -: Portfolio.populate('lists');