3. Consider the following documents in a collection called tastes { "favorite_foods": ["Pizza", "Chicken", "Donuts"] } { "favorite_foods": ["Fish", "Pizza", "Fruit salad"] } { "favorite_foods": ["Rice Pudding", "Fish", "Pizza"] } Which document(s) would be returned with the following query? db.tastes.find({ "favorite_foods": { "$all": [ "Pizza", "Fish" ] } }) Check all that apply:
题目选项
- A.1
- B.2
- C.3
答案置信度:高
正确答案:B、C
解析语言:中文
$all 要求数组字段同时包含所有给定元素:第 1 个文档的 favorite_foods 是 [Pizza, Chicken, Donuts],没有 Fish,不匹配;第 2 个 [Fish, Pizza, Fruit salad] 和第 3 个 [Rice Pudding, Fish, Pizza] 都同时含 Pizza 和 Fish,会被返回。所以答案是 B、C,即第 2 和第 3 个文档。