MongoDB DBA · Question 364 · Multiple choice

Which of the following documents in the people collection would be modified by the following query? db.people.updateMany( { state: "WA", city: "Seattle" }, { $pull: { likes: "hiking" } } ) Check all that apply:

Answer options

  1. A.
    { "_id": ObjectId("57fe664ed630a0fd9685a15f"), "firstName": "Charlie", "lastName": "Carlson", "state": "CA", "city": "San Diego", "likes": [ "desert", "beach" ] }
  2. B.
    { "_id": ObjectId("57fe664ed630a0fd9685a15e"), "firstName": "Beth", "lastName": "Barnes", "state": "WA", "city": "Richland", "likes": [ "forest", "desert" ] }
  3. C.
    { "_id": ObjectId("57fe664ed630a0fd9685a160"), "firstName": "Dawn", "lastName": "Davis", "state": "WA", "city": "Seattle", "likes": [ "forest", "mountains", "hiking" ] }
  4. D.
    { "_id": ObjectId("57fe664ed630a0fd9685a15d"), "firstName": "Arthur", "lastName": "Aaronson", "state": "WA", "city": "Seattle", "likes": [ "hiking", "dogs", "cats" ] }
  5. E.
    { "_id": ObjectId("57fe664ed630a0fd9685a161"), "firstName": "Evan", "lastName": "Erickson", "state": "WA", "city": "Seattle", "likes": [ "video games", "math" ] }

Answer confidence: High

Correct answer: C, D

Explanation language: Chinese

updateMany 先用 {state:"WA", city:"Seattle"} 过滤,再看 $pull 是否真的删掉了 likes 中的 hiking。A(CA/San Diego)、B(WA/Richland)不匹配过滤条件;E(Evan)虽匹配过滤条件,但 likes 里没有 hiking,$pull 不产生任何修改,不算被修改;只有 C 和 D 同时满足过滤条件且 likes 含 hiking,会被修改,故选 C、D。

Papers containing this question

This question appears in 2 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 ↗