1,798
社区成员




public List<CountIdDTO> listGroupCount(String groupField, String collectionName) {
Aggregation agg = Aggregation.newAggregation(Aggregation.group(groupField).count().as("count"),
Aggregation.project("count").and(groupField).as("objectId"));
AggregationResults<CountIdDTO> results = mongoTemplate.aggregate(agg, collectionName, CountIdDTO.class);
List<CountIdDTO> countIdDTO = results.getMappedResults();
return countIdDTO;
}
我写的代码是这样,测试错误