Last active
March 8, 2019 05:39
-
-
Save lenconda/fc0f0adbb71c8100c4aaa091c547e45e to your computer and use it in GitHub Desktop.
A MongoDB script to remove duplicates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.NEW_COLLECTION.ensureIndex({ 'KEY_TO_DISTINCT': 1 }, { 'unique': true, 'dropDups': true }); | |
db.DUMMY_COLLECTION.find().forEach(function(doc) { | |
db.NEW_COLLECTION.insert(doc); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment