i have a data that is
[{
"massName": "PI",
"month":7,
"member":
[
{
"name": "shamim",
"meal": [
],
"pyment":[
{
"07-07-2024":500
},
{
"13-07-2024":500
}
]
},
{
"name": "imran",
"meal": [
],
"pyment":[
{
"07-07-2024":300
},
{
"13-07-2024":500
}
]
},
{
"name": "hasibul",
"meal": [
],
"pyment":[
{
"07-07-2024":500
},
{
"13-07-2024":700
}
]
}
],
"bazar":[
{
"name":"shamim",
"date": "07-07-2024",
"amount":750
},
{
"name":"imran",
"date": "07-07-2024",
"amount":560
}
]
}
]
now i want to replace meal 2.5 to 4 for the member name shamim and date 07-07-2024. i try to solve it using many way but i failed. there’s some way
1.
db.massDetails.updateOne( { "member.name": "shamim", "member.meal.07-07-2024": { $exists: true } }, { $set: { "member.$.meal.'07-07-2024'": 3 } } )
2.
db.massDetails.updateOne( { "member.name": "shamim", "member.meal.07-07-2024": { $exists: true } }, { $set: { "member.$.meal": {'07-07-2024':3}} } )
please anyone give me the solution