【发布时间】:2020-12-22 08:13:36
【问题描述】:
样本数据:
let arrObj = [
{
"id": 9999,
"arrObj": [
{
"name": "xyz",
"arrId": 1,
"total1": 54,
"total2": 55
},
{
"type": "abc",
"arrId": 2,
"total1": 35,
"total2": 32
}
]
}
]
寻找 mongo 更新,例如:
db.coll('collectionName').update({
id: 9999,
arrObj.arrId: 1,
arrObj.total1 : {$lte : arrObj.total2}
},{$inc : {total2 : 1}})
我需要匹配 2 个字段,并基于它增加一个字段值。提前致谢。
【问题讨论】:
标签: mongodb mongoose mongodb-query