How can I update all documents in a collection? [SOLVED]

I want to add a new field to all documents in a collection. From within the meteor shell, I entered the following:

meteor:PRIMARY> db.myCollection.update({}, {$set: {newField: newValue}});

However, this was the response I got back, ie only one document in the collection was modified:

WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

Why was only one document modified? How can I update all documents in a collection?

you must add the multi option like this:

db.myColleciton.update({},{$set: {newField: newValue}}, {multi: true});
1 Like

Great, thanks! I knew it would be something simple like that.