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:
题目选项
- A.{ "_id": ObjectId("57fe664ed630a0fd9685a15f"), "firstName": "Charlie", "lastName": "Carlson", "state": "CA", "city": "San Diego", "likes": [ "desert", "beach" ] }
- B.{ "_id": ObjectId("57fe664ed630a0fd9685a15e"), "firstName": "Beth", "lastName": "Barnes", "state": "WA", "city": "Richland", "likes": [ "forest", "desert" ] }
- C.{ "_id": ObjectId("57fe664ed630a0fd9685a160"), "firstName": "Dawn", "lastName": "Davis", "state": "WA", "city": "Seattle", "likes": [ "forest", "mountains", "hiking" ] }
- D.{ "_id": ObjectId("57fe664ed630a0fd9685a15d"), "firstName": "Arthur", "lastName": "Aaronson", "state": "WA", "city": "Seattle", "likes": [ "hiking", "dogs", "cats" ] }
- E.{ "_id": ObjectId("57fe664ed630a0fd9685a161"), "firstName": "Evan", "lastName": "Erickson", "state": "WA", "city": "Seattle", "likes": [ "video games", "math" ] }
答案置信度:高
正确答案:C、D
解析语言:中文
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。