MongoDB DEV · Question 185 · Single choice

Consider a collection called products. Which of the following documents from the products collection will be returned by this query? db.products.find({ "brand": "appl" }, { "name": 1, "reviews.stars": 1 }) Choose the best answer:

Answer options

  1. A.
    { "name": "flip", "reviews": [ { "stars": 10 } ] }
  2. B.
    { "_id": ObjectId("5ab056adf1bdee44989b912e"), "name": "flip", "brand": "appl", "reviews": [ { "stars": 10 } ] }
  3. C.
    { "_id": ObjectId("5ab056adf1bdee44989b912e"), "name": "flip", "reviews": [ { "stars": 10 } ] }
  4. D.
    { "brand": "appl", "name": 1, "reviews": { "stars": 1 } }
  5. E.
    { "_id": ObjectId("5ab056adf1bdee44989b912e"), "brand": "appl" }

Answer confidence: High

Correct answer: C

Explanation language: Chinese

投影 { name: 1, reviews.stars: 1 } 只输出 name,以及 reviews 数组中每个子文档的 stars 字段;除非显式写 _id: 0,_id 默认保留,所以结果形如 { _id, name, reviews: [ { stars: 10 } ] },即 C。A 少了 _id(默认会带)、B 多带了被投影排除的 brand、D/E 的形态根本不是查询结果的写法。

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 ↗