How to remove duplicates based on a key in Mongodb?

后端 未结 8 835
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 20:56

I have a collection in MongoDB where there are around (~3 million records). My sample record would look like,

 { \"_id\" = ObjectId(\"50731xxxxxxxxxxxxxxxxxx         


        
8条回答
  •  忘掉有多难
    2020-11-30 21:15

    While @Stennie's is a valid answer, it is not the only way. Infact the MongoDB manual asks you to be very cautious while doing that. There are two other options

    1. Let the MongoDB do that for you using Map Reduce
      • Another way
    2. You do programatically which is less efficient.

提交回复
热议问题