我想要添加特定类别的特定月份的成本。这是我在MongoDB中存储的对象:
{
"2022":{
"January":{
"Food":30,
"Traveling":0,
"Medical":0,
},
"Feburary":{
"Food":1000,
"Traveling":0,
"Medical":50,
},
"March":{
"Food":100,
"Traveling":20,
"Medical":10,
}
}
}
现在,我提出一个补丁请求:
{
"month":"March",
"monthData":[70,45,100]
}
现在,我希望我的数据像这样更新:
{
"2022":{
"January":{
"Food":30,
"Traveling":0,
"Medical":0,
},
"Feburary":{
"Food":1000,
"Traveling":0,
"Medical":50,
},
"March":{
"Food":170,
"Traveling":65,
"Medical":110,
}
}
}
我应该使用Model.findAndUpate(Filter,Object)编写什么查询才能使上面的内容正常工作。
暂无答案!
目前还没有任何答案,快来回答吧!