MongoDB DEV · Question 67 · Multiple choice

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:

Answer options

  1. A.
    { "_id": 22, "a": 7, "b": -12, "c": 4 }
  2. B.
    { "_id": 20, "a": -2, "b": 19, "c": 17 }
  3. C.
    { "_id": 2, "a": 20, "b": -3, "c": 5 }

Answer confidence: High

Correct answer: A, C

Explanation language: Chinese

$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,不会被更新。

Papers containing this question

This question appears in 3 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗