I want to update every element in the array days
(I got 7 days, here I only show 3) with the MongoDB positional operator $[]
. The update correctly pushes an object into every single element of the array meals
. However, their Object Id's are the same, and I would like them to be different since I will be mapping them. Any ideas?
"_id": {
"$oid": "5db749cf657e1b1e0c3d241c"
},
"finished": false,
"days": [
{
"dayName": "Monday",
"meals": [
{
"_id": {
"$oid": "5dba1cde12f2b650e4b4f89d"
},
"mealName": "Breakfast",
"recipes": []
}
]
},
{
"dayName": "Tuesday",
"meals": [
{
"_id": {
"$oid": "5dba1cde12f2b650e4b4f89d"
},
"mealName": "Breakfast",
"recipes": []
}
]
},
{
"dayName": "Wednesday",
"meals": [
{
"_id": {
"$oid": "5dba1cde12f2b650e4b4f89d"
},
"mealName": "Breakfast",
"recipes": []
}
],
}
]
}