Answer the question
In order to leave comments, you need to log in
Remove duplicate documents in MongoDb?
Faced such task: It is
necessary to remove duplicates in a collection provided that 'owner' == ''.
I use MongoDB and Mongoose.
How to delete these documents. The procedure will be repeated daily, records up to 20,000?
Answer the question
In order to leave comments, you need to log in
db.myCollection.find({}, {myCustomKey:1}).sort({_id:1}).forEach(function(doc){
db.myCollection.remove({_id:{$gt:doc._id}, myCustomKey:doc.myCustomKey});
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question