java驱动程序中的mongodb聚合函数实现

时间:2017-03-29 05:49:53

标签: mongodb mongodb-query aggregation-framework

如何在java中实现这个聚合查询我不知道该怎么办?

db.History.aggregate([ 
    { "$match" : {"thId":"001"}},
    { "$group" : { 
              "_id" : {"Id":"$Id","controller" : "$controller","mod" : "$mod","variable" : "$variable"}  
              ,"variable" : {"$first": "$$ROOT"}
              ,"data" : {"$push":{"value":"$value","updatedDateTime":"$updatedTime"}}
            }
    }
    ])

1 个答案:

答案 0 :(得分:1)

参考Mongo Java Driver Documentation

.goxc.json