8 lines
260 B
Plaintext
8 lines
260 B
Plaintext
db.clients.aggregate([
|
|
{ $group: {
|
|
_id: { companyId: "$companyId", email: { $toLower: "$email" } },
|
|
count: { $sum: 1 },
|
|
emails: { $addToSet: "$email" }
|
|
} },
|
|
{ $match: { count: { $gt: 1 }, $expr: { $gt: [{ $size: "$emails" }, 1] } } }
|
|
]) |