概要本文主要讲述在 mongodb 中,怎么更新嵌套数组的值。 使用$更新数组
测试
.find.foreach + save (循环判断保存法)
利用arrayFilter
db.collection.updateMany( { <query conditions> }, { <update operator>: { "<array>.$[<identifier>]" : value } }, { arrayFilters: [ { <identifier>: <condition> } ] } )
注意
|
|