So, I have 3 schemas,
User
const UserSchema = new mongoose.Schema({
...,
weekly: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Weekly'
}]
});
Weekly
const weeklyAnalyticSchema = new mongoose.Schema({
daily: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'DailyAnalytic'
}],
weekStart: {
type: Date,
// default: addDaystoDate(1)
},
weekEnd: {
type: Date,
// default: addDaystoDate(7)
}
})
Daily
const Daily = new mongoose.Schema({
date: Date,
foo: bar
})
I'm trying to populate the daily array inside the weekly array, like so...
I do this, following the documentation from mongoosejs mongoose deep populate
let found = await db.User.findById(req.user._id).populate({
path: "weeklyAnalytics",
populate: {
path: "dailyAnalytics"
}).exec()
and it comes out like this
daily: [ 1],
weekly: [
{
daily: [Array],
_id: 1,
__v: 0
}
],
i've tried many others as well and read and modified other peoples code, but I can't seem to get that daily inside the weekly to populate.