Created
July 25, 2018 21:16
-
-
Save adamgen/907072a230ddbcb1a4220fd0c7072ff3 to your computer and use it in GitHub Desktop.
This file contains 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
// change old_key_name with new_key_name | |
db.collection.find().forEach(function(document) { | |
var old_key_name = document.old_key_name; | |
db.collection.update( | |
{ _id: document._id }, | |
{ | |
$set: { | |
new_key_name: old_key_name, | |
}, | |
$unset: { old_key_name: '' } | |
} | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment