0
db.coll.update({},{$set:{deleted: 0}});

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

Only one and first one document is updated.

Why not every documents be updated?

Sato
  • 8,192
  • 17
  • 60
  • 115
  • 4
    use [{multi:true}](http://docs.mongodb.org/manual/reference/method/db.collection.update/#multi-parameter) – Neo-coder Jul 29 '15 at 10:20
  • To clarify the `WriteResult` quoted above, this can only happen if the "first" document matched already has the same property value as what is being `$set`. And of course is usually because the OP here already ran the operation once before quoting that output. Otherwise the "first" would be `"nModified": 1` as equal to `"nMatched"` – Blakes Seven Jul 29 '15 at 10:54

0 Answers0