MongoDB - Delete duplicate records

Viewed 24

We had an issue with some automated processing and ended up with a bunch of dupes in Mongo in a single collection. I've got 7 records where I should only have 1, but I'm not sure how to go about this 100% and looking for some guidance.

I've sorted out the query and my return records look like this: Mongo Duplicates Query

What's the best way to remove these dupes?

1 Answers

My first thought is that you can fetch all the data you have, loop through every item and find all other objects with its same id. If found, delete them.

Related