Wednesday, February 10, 2016

MongoDB "update" Only Updates One Entry by Default

The "update" command only updates the first matching entry by default. To update all entries, there is a third parameter i.e. "options" where you need to set "multi: true" e.g.
db.coll.update({},{$set:{"attr":”value”]}},{multi:true})

Reference: https://docs.mongodb.org/v2.4/reference/method/db.collection.update/

No comments:

Post a Comment