hello
发布于 2022-04-12 / 3 阅读
0
0

java mongodb聚合查询 怎么用代码实现

db.getCollection(‘workers’).aggregate(
{‘$group’:{
‘_id’: {‘workerId’: ‘$workerId’},
‘uniqueIds’: {‘$addToSet’: ‘$_id’},
‘count’ : {‘$sum’: 1}
}},
{‘$match’: {
‘count’: {‘$gt’: 1}
}}

)


评论