how to i push value in double nested array as shown in below code !!
{
"_id" : ObjectId("627ce38702f566ef8e89977a"),
"name" : "max",
"sub" : {
"type" : "maths",
"grades" : [
{
"semOne" : [
7,
8,
9
]
},
{
"semTwo" : [
9,
11,
12
]
}
]
}
}
let say i want to add 13 in semOne, how do i add ??
2
Answers
Probably like this:
Try this:
You might have facing error that .push is not a function, because "grades" is an array and here you have to define object position to push something.
You can use
$push
in update witharrayFilters
.Here is the Mongo playground for your reference.