On this page本页内容
$setIsSubset¶Takes two arrays and returns 获取两个数组,当第一个数组是第二个数组的子集时返回true when the first array is a subset of the second, including when the first array equals the second array, and false otherwise.true,包括当第一个数组等于第二个数组时,否则返回false。
$setIsSubset has the following syntax:语法如下所示:
The arguments can be any valid expression as long as they each resolve to an array. 参数可以是任何有效的表达式,只要它们各自解析为一个数组。For more information on expressions, see Expressions.有关表达式的详细信息,请参阅表达式。
$setIsSubset performs set operation on arrays, treating arrays as sets. 对数组执行集合操作,将数组视为集合。If an array contains duplicate entries, 如果数组包含重复的条目,$setIsSubset ignores the duplicate entries. $setIsSubset将忽略重复的条目。$setIsSubset ignores the order of the elements.忽略元素的顺序。
If a set contains a nested array element, 如果集合包含嵌套数组元素,$setIsSubset does not descend into the nested array but evaluates the array at top-level.$setIsSubset不会下降到嵌套数组中,而是在顶级对数组求值。
| Result | |
|---|---|
| true | |
| false | 
Consider an 考虑一个experiments collection with the following documents:experiments集合,带有下列文档:
The following operation uses the 以下操作使用$setIsSubset operator to determine if the A array is a subset of the B array:$setIsSubset运算符确定A数组是否为B数组的子集:
The operation returns the following results:操作返回以下结果: