我的问题是,我有一个这样的收藏集:
"cost_price" : 79.9,
"list_price" : 189.9,
"sale_price" : 189.9,
"integrations" : {
"erp" : {
"mbm" : {
"cost_price" : 79.9,
"list_price" : 189.9,
"sale_price" : 189.9
},
"linx" : {
"cost_price" : 79.9,
"list_price" : 189.9,
"sale_price" : 200.1
}
},
"marketplace" : {
"netshoes" : {
"list_price" : 189.9,
"sale_price" : 199.9
}
},
"ecommerce" : {
"vtex" : {
"list_price" : 189.9,
"sale_price" : 189.9
},
"magento" : {
"list_price" : 189.9,
"sale_price" : 189.9
}
}
}
如何通过单个查询更新此集合中所有名为“ list_price”的字段?
答案 0 :(得分:0)
可能会帮助您。
db.products.updateMany({}, {
$rename: {
"list_price": "new_name",
"integrations.erp.mbm.list_price": "new_name",
"integrations.erp.linx.list_price": "new_name",
"integrations.erp.linx.list_price": "new_name",
"integrations.marketplace.netshoes.list_price": "new_name",
"integrations.ecommerce.vtex.list_price": "new_name",
"integrations.ecommerce.magento.list_price": "new_name"
}})