Answers for "duplicated documens mongodb"

0

duplicated documens mongodb

db.users.aggregate([
    {$group: {
        _id: {email: "$email"},
        uniqueIds: {$addToSet: "$_id"},
        count: {$sum: 1}
        }
    },
    {$match: { 
        count: {"$gt": 1}
        }
    },
    {$sort: {
        count: -1
        }
    }
]);
Posted by: Guest on October-16-2020

Browse Popular Code Answers by Language