How to make duplicate collection in MongoDB code example
Example: duplicated documens mongodb
db.users.aggregate([
{$group: {
_id: {email: "$email"},
uniqueIds: {$addToSet: "$_id"},
count: {$sum: 1}
}
},
{$match: {
count: {"$gt": 1}
}
},
{$sort: {
count: -1
}
}
]);