I have this parto of query in mongo that return an array of fields.
{ $project:
{
...
result:
[
{ sumShotsOfOneAttempted: '$sumShotsOfOneAttempted1', sumShotsOfOneFailed: '$sumShotsOfOneFailed1'},
{ sumShotsOfOneAttempted: '$sumShotsOfOneAttempted2', sumShotsOfOneFailed: '$sumShotsOfOneFailed2'}
]
}
}
I'm trying to build the same with spring-mongodb using ProjectionOperation:
ProjectionOperation projectStage = Aggregation.project("fieldId");
And I want to add the fields inside of array to this projectStage, but I only know how to add one by one as projectStage.and("sumShotsOfOneAttempted1").as(sumShotsOfOneAttempted);
but not arrays.
My depndendencies of spring.mongodb:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
Any idea please?