1// If you want to add a new_field to all your collection, you have to use empty
2// selector, and set multi flag to true (last param) to update all the documents
3
4db.your_collection.update(
5 {},
6 { $set: {"new_field": 1} },
7 false,
8 true
9)
10// In the above example last 2 fields false, true specifies the upsert and multi flags.
11// Upsert: If set to true, creates a new document when no document matches the query criteria.