mongoTemplate Aggregation first


       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是接收類中的字段


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM