Hello @Krishna, Welcome to MongoDB community forum,
You can try update with aggregation pipeline starting from MongoDB 4.2,
-
$map
to iterate loop ofOrders
array -
$map
to iterate loop ofItems
array and renameStockCode
property toArticleNo
and return other fields -
$mergeObjects
to merge current object ofOrders
and update propertyItems
db.collection.updateMany(
{},
[{
$set: {
"Configuration.Orders": {
$map: {
input: "$Configuration.Orders",
in: {
$mergeObjects: [
"$$this",
{
Items: {
$map: {
input: "$$this.Items",
in: {
ArticleNo: "$$this.StockCode",
OrderedQuantity: "$$this.OrderedQuantity"
}
}
}
}
]
}
}
}
}
}]
)