Consider the following query against the items collection: db.items.updateMany( { $and: [ { price: { $gte: 5 } }, { price: { $lte: 7 } } ] }, { $set: { quantity: 12 } } ) Which of the following documents will be updated by this query? Check all that apply:
题目选项
- A.{ "_id": 44, "name": "gizmo", "price": 6, "quantity": 5 }
- B.{ "_id": 22, "name": "wrench", "price": 7, "quantity": 4 }
- C.{ "_id": 55, "name": "widget", "price": 10, "quantity": 17 }
答案置信度:高
正确答案:A、B
解析语言:中文
过滤条件是 price >= 5 且 price <= 7,因此 price 为 6 的 gizmo 与 price 为 7 的 wrench 都会被 $set quantity:12。price=10 超出了上界,不会被更新。