Sample Document from Collection
{
"_id" : 2,
"student" : "Ryan",
"homework" : [
5,
6,
5
],
"quiz" : [
8,
8
],
"extraCredit" : 8
}
Aggregation Query in mongodb
db.scores.aggregate([
{
$project : {
_id:"$_id",
hSum : { $sum: "$homework" },
qSum : { $sum: "$quiz"},
}
}])
Output Of above aggregation query
{
"_id" : 2,
"hSum" : 16,
"qSum" : 16
}
I want to convert above mongo query in spring-data format. I want to do aggregation with projectionOperations in spring data. how to write with projectionOperation ?