db.getCollection(‘workers’).aggregate(
{‘$group’:{
‘_id’: {‘workerId’: ‘$workerId’},
‘uniqueIds’: {‘$addToSet’: ‘$_id’},
‘count’ : {‘$sum’: 1}
}},
{‘$match’: {
‘count’: {‘$gt’: 1}
}}
)
db.getCollection(‘workers’).aggregate( {‘$group’:{ ‘_id’: {‘workerId’: ‘$workerId’}, ‘uniqueIds’: {‘$addToSet’: ‘$_id’}, ‘count’ : {‘$sum’: 1} }}, {‘$match’: { ‘count’: {‘$gt’: 1}…
一起交流
分享你的思考,让讨论更进一步。