Skip to content

Instantly share code, notes, and snippets.

@adamgen
Created July 25, 2018 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamgen/907072a230ddbcb1a4220fd0c7072ff3 to your computer and use it in GitHub Desktop.
Save adamgen/907072a230ddbcb1a4220fd0c7072ff3 to your computer and use it in GitHub Desktop.
// 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