MongoDB DEV · Question 179 · Single choice

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:

Answer options

  1. A.
    This query will generate an error
  2. B.
    1
  3. C.
    0
  4. D.
    2
  5. E.
    5

Answer confidence: High

Correct answer: B

Explanation language: Chinese

delete 命令中 limit: 1 表示"最多删除一条匹配文档",所以 {a:4} 匹配到的 _id 2、_id 3 中只会删掉一条,答案是 1。limit 只接受 0(全部)或 1,其他取值才会报错,所以 E 不成立;本题选项位置与 A./B. 标签已核对一致,"B.1" 位于下标 1,即字母 B。

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 ↗