Mongo update/remove multiple fields
Posted on June 28, 2012 | Categories: Technology
To remove fields from documents in a collection use:
db.test.update({data:{$exists:true}},{$unset:{data:1}},{multi:1});
Or, if you want to add new fields, use set:
db.test.update({data:{$exists:false}},{$set:{data:"your value"}},{multi:1});
Set “multi” to 1 if you want to update/remove all documents that match the criteria.