Skip to content

Instantly share code, notes, and snippets.

@zladuric
Created December 2, 2015 11:20
Show Gist options
  • Save zladuric/52bba4c15872c389a026 to your computer and use it in GitHub Desktop.
Save zladuric/52bba4c15872c389a026 to your computer and use it in GitHub Desktop.
// Create something to test
db.test.insert({deep: {prop: 5}});
// Rename field
db.test.update({'deep.prop': {$exists: true}}, {$rename: {'deep.prop': 'deep.property'}}, {multi: true});
// Move to another object
// Note: leaves dangling `deep: {}`
db.test.update({'deep.property': {$exists: true}}, {$rename: {'deep.property': 'deeper.deep.property'}}, {multi: true});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment