I have a document structured like this:
{
"shedule": [
{
"SUN": {
"status": false,
"task": []
}
},
{
"MON": {
"status": false,
"task": []
}
},
]
}
How to update status to false and push new element to task array in sun object.
Here is the expected output.
{
"shedule": [
{
"SUN": {
"status": true,
"task": [1,2]
}
},
{
"MON": {
"status": false,
"task": []
}
},
]
}
asked Aug 26, 2021 at 4:07
Sufail Kalathil
65614 silver badges29 bronze badges
1 Answer 1
If your SUM always at the first place, this is the answer:
db.collection.update(
{},
{
$push: {
"shedule.0.SUN.task": {
$each: [ NumberInt(1), NumberInt(2) ] } },
$set: { "shedule.0.SUN.status": true }
}
)
answered Aug 26, 2021 at 5:46
YuTing
6,6692 gold badges8 silver badges19 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js