I am trying to update the 'expelled' field to true, when students' ages are 13, and 'strikes' count is 3 - in the school with an ID of 101.
To rephrase it, how do I update a value in an object that is found based on a query of two matching criteria within the object being updates. An illustration of the collection is below.
collection: [
{ schoolID: 101,
students: [
{
name: "Jim",
age: 13,
strikes: 3,
expelled: false
},
{
name: "Zack",
age: 13,
strikes: 0,
expelled: false
},
{
name: "Sarah",
age: 11,
strikes: 1,
expelled: false
}
]
},
{ schoolID: 102,
students: [...]
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…