Updating all records in MongoDB collection and adding a new field
Let say you have an existing collection and you want to add a new fields active:true to all the existing documents, then you can run the following query
db.myCollection.update({}, {$set: {"active": true}}, false, true);