Consider the following query against the sample collection: db.sample.updateMany( { $or: [ { a: { $gte: 5 } }, { b: { $lte: 7 } } ] }, { $set: { c: 12 } } ) Which of the following documents will be updated by this query? Check all that apply:
题目选项
- A.{ "_id": 22, "a": 7, "b": -12, "c": 4 }
- B.{ "_id": 20, "a": -2, "b": 19, "c": 17 }
- C.{ "_id": 2, "a": 20, "b": -3, "c": 5 }
答案置信度:高
正确答案:A、C
解析语言:中文
$or 只要任一条件成立就命中并更新:_id 22 的 a=7 满足 a>=5,_id 2 的 a=20 也满足 a>=5,两条都会被 $set c:12。_id 20 的 a=-2 不满足 a>=5、b=19 也不满足 b<=7,不会被更新。