feat: agregar lógica para evitar duplicados de clientes por email y vincular usuarios existentes
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
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] } } }
|
||||
])
|
||||
Reference in New Issue
Block a user