Consider a collection called stuff which only contains the following documents: { "_id": 1, "a": 1, "b": 1 } { "_id": 2, "a": 4, "b": 3 } { "_id": 3, "a": 4, "b": 6 } { "_id": 4, "a": 2, "b": 10 } { "_id": 5, "a": 5, "b": 15 } You perform the following operation: db.runCommand( { delete: "stuff", deletes: [ { q: { a: 4 }, limit: 1 } ] } ) How many documents will be deleted as a result of this operation? Choose the best answer:
题目选项
- A.This query will generate an error
- B.1
- C.0
- D.2
- E.5
答案置信度:高
正确答案:B
解析语言:中文
delete 命令中 limit: 1 表示"最多删除一条匹配文档",所以 {a:4} 匹配到的 _id 2、_id 3 中只会删掉一条,答案是 1。limit 只接受 0(全部)或 1,其他取值才会报错,所以 E 不成立;本题选项位置与 A./B. 标签已核对一致,"B.1" 位于下标 1,即字母 B。