I´ve read a couple of other posts here on Stackoverflow but havent found any 'general' answer.
Lets say I have a Structure like this:
{
personsName: "Bob",
children: [
{childsName: "Alice", age: "9", weight: "40"}
{childsName: "Peter", age: "12", weight: "80"}
]
}
Now I want to edit Peters weight because it is actually "45"
I tried:
.update(
{ personsName: "Bob", children.childsName: "Peter"},
{
$set: {children: {weight :"45" } }
}
)
For me this should be working...Update the childrens weight to "45" for all children that are named "Peter" and belong to "Bob"... I saw some solutions where they update the array by index, but lets assume we dont know the index, we want to update by the childs property "childsName".
Whats the general way of doing that?