steevej
(Steeve Juneau)
2
Yes. If modifiedCount is smaller than matchedCount, it means that some matched documents were not modified because they already contained the correct updated value. For example,
{ _id : 0 , a : 0 , b : 2 }
{ _id : 1 , a : 0 , b : 3 }
updateMany( { a : 0 } , { $set : { b : 2 } } )
Both documents _id:0 and _id:1 match the query a:0 so matchedCount=2 but since _id:0 already has b:2 it is not modified. Then modifiedCount=1.
I have not seen a condition where modifiedCount is > matchedCount.
I do not know.