I'm just wondering how I can update a nested array field inside a mongo db document.
Here is how my schema looks like:
const userSchema = new Schema({
email: {type: String, unique: true, lowercase: true},
password: String,
firstName: String,
lastName : String,
role: String,
children: Array
});
This is how the document looks like:
{
"_id" : ObjectId("5b3570f3150a0b57a4e7421e"),
"children" : [
{
"fullName" : "John doe",
"yearGroup" : "4",
"absences" : [],
"id" : "765"
}
],
"email" : "[email protected]",
"firstName" : "John",
"lastName" : "Doe",
"role" : "parent",
"__v" : 1
}
Where I want to push a new object into to 'absences' array.