Reputation: 18097
If I'm not mistaken $set
in the following will add the field if it doesn't exist.
db.coll.update({profession:"devs"}, { $set : { daysSpent : 30 } }, {multi:true});
it will set daysSpent
30 for all docs with profession "devs" regardless of whether they have this field.
Upvotes: 1
Views: 1282