mongodb - Update many values in nested array mongodb
问题描述
I'm stucked how to update many second level nested array values
How to update in mongodb only all "ware amount" in "wares" (sizes.wares.amount) to 0 (zero) where ware (sizes.wares.ware) is "SFO" in here is the mongo data
{
{
"_id" : ObjectId("5dc1c8f2e3341fc38ef47698"),
"productCode" : xxxx",
"sizes" : [ {
"size" : "35",
"wares" : [
{"ware" : "SFO", "amount" : "11" },
{"ware" : "LAX","amount" : "22"}
]
},
{
"size" : "36",
"wares" : [
{"ware" : "SFO", "amount" : "33"},
{ "ware" : "LAX", "amount" : "44"}
]
},
]
},
{
"_id" : ObjectId("5f23e19e6fff1017d2d8e8f1"),
"productCode" : "yyyy",
"sizes" : [
{"size" : "35",
"wares" : [
{"ware" : "SFO", "amount" : "255"},
{ "ware" : "LAX","amount" : "333"}
]
},
{
"size" : "36",
"wares" : [
{"ware" : "SFO", "amount" : "444"},
{"ware" : "LAX","amount" : "777"}
]
}
]
}
}
Thanks in advanced
Juha
解决方案
推荐阅读
- c# - PhilipsHue XY Bri 转 RGB(不含 Philips Hue SDK)
- powershell - 等待 Active Directory 身份验证 URL 列表在 Powershell Azure 函数中更新
- c# - 在字符串数组c#中使用“foreach”
- http - Postman 在使用 Rossum API 时显示 CSRF 错误
- r - Shinyapps.io 应用程序部署失败。如何调试不明确的错误日志?
- javascript - 如何使用codeigniter在MYSQL数据库中使用数组索引上传文件
- python-3.x - 如何在单独的作业中或异步地为烧瓶 request.files.getlist('images') 中的多个图像实现 image.read()
- c - 尽管没有到达字符串的末尾,strtok 返回 NULL
- arrays - 匹配不同大小数组的索引
- java - 在 graphql 方案中使用 Date 类型