Reputation: 167
I have a MongoDB aggregation query, I need the Spring boot mongo aggregation object example for the Following query.
db.case.aggregate([
{ $project: { item: { $concatArrays: [ "$workApproval.partItems", "$warrantyClaims.items.items" ] } } }
,{ $unwind : "$item"}
])
I am stuck on the concatArray portion, I am not sure how to write the above query in Spring Boot Mongo aggregation, any help is appreciated.
Upvotes: 1
Views: 2810
Reputation: 3144
Here you are:
List<AggregationOperation> operations = new ArrayList<>();
operations.add(
Aggregation.project()
.and("workApproval.partItems").concatArrays("warrantyClaims.items.items").as("item")
);
operations.add(Aggregation.unwind("item"));
Aggregation aggregation = Aggregation.newAggregation(operations);
Upvotes: 3