Reputation: 1511
(1) What's the fastest way to check if an item I'm about to "insert" into a MongoDB collection is unique (and if so not insert it)
(2) For an existing database, what's the fastest way to look at all the entries and remove duplicates but keep one copy i.e. like a "set" function: {a,b,c,a,a,b} -> {a,b,c}
Thanks!
Upvotes: 0
Views: 833
Reputation:
(1) Create a unique index on the related columns and catch the error upon insertion time
Upvotes: 2