$inc在更新中对一个数字有效-
{
_id:1,
data:5
}
可以更新数据-
^{pr2}$数据是更新后的总和-
{
_id:1,
data:15
}
但是,我不能对数字数组这样做-
{
_id:1,
data:[1,2,3,4,5,6]
}
我需要一些像-
db.collection.update({}, {$inc:{data:[1,1,1,1,1,1]}}
收到错误-
"code" : 14,
"errmsg" : "Cannot increment with non-numeric argument: {pnl: [...]}"
这是我需要的结果-
{
_id:1,
data:[2,3,4,5,6,7]
}
你能建议我,我怎样才能做到这一点?在
您需要使用bulkAPI并使用
[]
运算符动态构建查询。在也可以在shell中这样做:
^{pr2}$相关问题 更多 >
编程相关推荐