Mongo db update gotcha

27th Mar, 2012 | mongodb

I was trying to remove an array field from a collection and it wasn't working. Turned out the update command defaults to only updating the first found record rather than all (as sql would)

Standard update syntax to update all fields:

db.mycollection.update({}, { $unset : { myarray : 1}}, false, true);