java 操作mongodb Aggregation 分组查询及 排序


直接上代码:
Aggregation agg = Aggregation.newAggregation(Resional.class,
Aggregation.match(Criteria.where("createTime").gte(req.getStartTime())
.lte(req.getEndTime())),
Aggregation.group("createUserId").count().as("count"),
Aggregation.sort(Sort.Direction.DESC, "count")
);
AggregationResults<ExportExcelResourceListDto> aggregate =
mongoTemplate.aggregate((TypedAggregation<?>) agg,
ExportExcelResourceListDto.class);
return aggregate.getMappedResults();



免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM