Want to Update Array of Array Object Value in Mongo

别等时光非礼了梦想. 提交于 2019-12-04 15:31:15

try the following query for update

db.stack.update({"options.0.stores":{$elemMatch:{code:"AND1"}}},{$set:{"options.0.stores.$.inventory":200}})

for check i'll update with images....

i had taken the your data as example

now i had used the above query db.stack.update({"options.0.stores":{$elemMatch:{code:"AND1"}}},{$set:{"options.0.stores.$.inventory":200}})

then the result is shown in the following image

i had update the inventory to 200 where code:"AND1"

see the changes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!