zoukankan      html  css  js  c++  java
  • 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是接收类中的字段
  • 相关阅读:
    常用jquery
    常用记录
    mysql proxy 读写分离
    Linux 学习笔记
    php 1116
    php 1115
    php 1110
    php 1109
    php 1108
    php 1105
  • 原文地址:https://www.cnblogs.com/lovetl/p/13306268.html
Copyright © 2011-2022 走看看