I have an issue getting the sum of an array of objects, Document is mentioned below.
{
"orderNumber":123,
"items":[
{
"price":2
},
{
"price":10
}
]
}
I need the below document
{
"orderNumber":123,
"totalItemsValue":12,
"items":[
{
"price":2
},
{
"price":10
}
]
}
Sum of prices in totalItemsValue field.I need a solution in spring mongo data.I will be thankful.