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

)

— 感谢阅读 —
广告

一起交流

分享你的思考,让讨论更进一步。