To find duplicate entries in MongoDB based on the code and user_id fields, you can use the aggregate method along with the $group and $match pipeline stages. Here is an example of how to do this: Let's take the example collection - user_collection . { "_id" : ObjectId( "640054ef881f521a7b68fc96" ) , "code" : "google_uploader" , "user_id" : "33052" , "type" : "uploader" , "charge_type" : "Prepaid" , "available_credits" : 500 , "total_used_credits" : 0 } { "_id" : ObjectId( "640054ef881f521a7b68fc99" ) , "code" : "google_uploader" , ...