mongodb find duplicates in array across documents -


having array of emails on document. how find document in same collection shares @ least 1 email in common?

essentially have contacts collection , each contact document has array of emailaddresses[]. want make sure no 2 contact documents have email in common document, we're unable find happening.

db.collection.aggregate([ {"$unwind" : "$emails"}, {$group  : {"_id" : "$emails" , "count" :{"$sum" : 1} }}, {"$match" : {"count" : {"$gt" : 1}}} ]) 

this result emails dupicate


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -