Which factory class should be used for building aggregation pipeline stages?
The Aggregates class
Which factory class can be used to sort data?
The Sorts class
Which factory class can be used to project data?
The Projections class
Code an example of the aggregation pipeline strucutre
collection.aggregate(List.of(Aggregates1, Aggregates2, ...))
Code an example using the match stage with multiple field criteria
var matchStage = match(and(eq(field, value), eq(field2, value2))); collection.aggregate(List.of(matchStage));
Code an example using the group stage
var groupStage = group("$groupKey", Accumulators...));
collection.aggregate(List.of(groupStage));Which class should you use to perform accumulator operations?
The Accumulators class
Code an example using an ascending sort and limit stage
var sortStage = sort(Sorts.ascending(field1, field2)); var limitStage = limit(number); collection.aggregate(List.of(sortStage, limitStage));
Code an example of using the project stage
var projectStage = project(Projections...); document.aggregate(List.of(projectStage));
Code an example using the out stage
var outStage = out("collectionName");
collection.aggregate(List.of(outStage));