MongoDB DBA · Question 425 · Single choice

58. Consider the following query: db.movies.find( {"countries.0": "France", "genres.0": "Documentary"}, {"countries":1, "genres":1, "title":1, "year":1, "_id":0} ) Choose the best answer:

Answer options

  1. A.
    { "genres" : [ "Documentary", "History", "Music" ], "title" : "Woodstock", "year" : 1970, "countries" : [ "USA" ] }
  2. B.
    { "_id" : ObjectId("573a1399f29313caabcedc24"), "genres" : [ "Documentary" ], "title" : "It's All True", "year" : 1993, "countries" : [ "France", "USA" ] }
  3. C.
    { "genres" : [ "Documentary" ], "title" : "Nanook of the North", "year" : 1922, "countries" : [ "USA", "France" ] }
  4. D.
    { "genres" : [ "Documentary" ], "title" : "F for Fake", "year" : 1973, "countries" : [ "France", "Iran", "West Germany" ] }

Answer confidence: High

Correct answer: D

Explanation language: Chinese

countries.0 与 genres.0 只匹配数组的第一个元素,因此文档必须满足 countries[0]="France" 且 genres[0]="Documentary",D 正确(投影里有 _id:0,输出不应出现 _id)。B 仍然输出了 _id,直接排除;A 的 countries[0] 是 USA、C 的 countries[0] 也是 USA,都不满足条件。

Papers containing this question

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