Try:
db.collection.update( { '<field>': { '$exists': true } }, // Query { '$unset': { '<field>': true } }, // Update false, // Upsert true // Multi-update )
where field is your deprecated field, and collection is the collection from which it was deleted.
The general update command has the form db.collection.update( criteria, objNew, upsert, multi ) . The returned false and true arguments turn off the upsert mode and activate multiple updates so that the request updates all documents in the collection (and not just the first match).
Update for MongoDB 2.2 +
Now you can provide a JSON object instead of positional arguments for upsert and multi.
db.collection.update( { '<field>': { '$exists': true } }, // Query { '$unset': { '<field>': true } }, // Update { 'multi': true } // Options )
Tyler Brock Dec 27 '11 at 17:24 2011-12-27 17:24
source share