In my mongoose schema, I have the following structure:
var AttendanceSchema = new mongoose.Schema({
ownerId: mongoose.Schema.Types.ObjectId,
companyId: mongoose.Schema.Types.ObjectId,
months: [
{
currentSalary: {
type: Number,
default: 0
},
month: {
type: Date,
},
salary: {
type: Number,
default: 0
}
days: [
{
manuallyUpdated: {
type: Boolean,
default: false
},
date: {
type: Date,
},
perDaySalary: {
type: Number,
default: 0
},
status: {
type: String,
}
}
]
}
]
});
My goal is to extract a single object from the days array.
Note: The days array is nested within the months array. Although I have used $pull to remove that day object, I now need to pull and push it again (update the day).