Java – spring Mongo > how to get the list aggregationoperations from aggregation
•
Java
I have a function that takes aggregation as a parameter
I want to get all aggregationoperations from the aggregation Is there any way?
public Aggregation newCustomAggregation(Aggregation aggregation,Criteria c) { // How to get list operation aggregation there? listOperation.push(Aggregation.match(c)); return Aggregation .newAggregation(listOperations); }
My goal is to use my custom matchaggregation to create another aggregation
Solution
You can create your own custom aggregation implementation by inheriting aggregation to access protected action fields
It's like
public class CustomAggregation extends Aggregation { List<AggregationOperation> getAggregationOperations() { return operations; } } public Aggregation newCustomAggregation(Aggregation aggregation,Criteria c) { CustomAggregation customAggregation = (CustomAggregation) aggregation; List<AggregationOperation> listOperations = customAggregation.getAggregationOperations(); listOperations.add(Aggregation.match(c)); return Aggregation .newAggregation(listOperations); }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码