Skip to content

Instantly share code, notes, and snippets.

@lexer
Created December 29, 2011 08:49
Show Gist options
  • Save lexer/1533021 to your computer and use it in GitHub Desktop.
Save lexer/1533021 to your computer and use it in GitHub Desktop.
How to remove deprecated fields in mongo?
db.collection.find().forEach(function(x) {
delete x.badField;
db.collection.save(x);
})
db.collection.update( { field: { $exists: true } }, {$unset: { field : 1 } }, false, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment