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
- A.{ "name": "flip", "reviews": [ { "stars": 10 } ] }
- B.{ "_id": ObjectId("5ab056adf1bdee44989b912e"), "name": "flip", "brand": "appl", "reviews": [ { "stars": 10 } ] }
- C.{ "_id": ObjectId("5ab056adf1bdee44989b912e"), "name": "flip", "reviews": [ { "stars": 10 } ] }
- D.{ "brand": "appl", "name": 1, "reviews": { "stars": 1 } }
- 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 的形态根本不是查询结果的写法。