首页 > 其他 > 详细

mongoTemplate Aggregation first

时间:2020-07-15 19:59:56      阅读:143      评论:0      收藏:0      [点我收藏+]
       Aggregation managerSum = Aggregation.newAggregation(
                Aggregation.group("_id").first("by_user").as("by_user").first("title").as("title")
                        .count().as("jiShu")
        );

显示结果

Runoob(id=5ee97bd3fd4200000c000618, title=MongoDB Overview, description=null, by_user=runoob.com1, url=null, tags=null, likes=null, jiShu=1)
Runoob(id=5ee97bd3fd4200000c00061a, title=Neo4j Overview, description=null, by_user=runoob.com2, url=null, tags=null, likes=null, jiShu=1)
Runoob(id=5f0eb8a55f07000038007f94, title=runoob.com2, description=null, by_user=runoob.com2, url=null, tags=null, likes=null, jiShu=1)
Runoob(id=5ee97bd3fd4200000c000619, title=NoSQL Overview, description=null, by_user=runoob.com, url=null, tags=null, likes=null, jiShu=1)

没有加first在结果中就没有显示

first("title")//此title是数据中的字段
as("title")//此title是接收类中的字段

mongoTemplate Aggregation first

原文:https://www.cnblogs.com/lovetl/p/13306268.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!