isSubset - Check if one array is contained within another array
Returns true if array1 is a subset of array2.
NOTE: When comparing array1
and array2
, duplicates will be discarded. This means two arrays of differing lengths but the same unique elements will be considered equal.
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
array1 | array of type T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
array2 | array of type T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
Example - Basic usage
Consider the following document:
If we wish to check that started_jobs
is a subset of all_jobs
, we can do the following:
This results in the following document:
{
"all_jobs": ["Chris", "John", "Adam", "Ariel", "Zev"],
"started_jobs": ["Chris", "John"],
"is_subset": true
}
Theme
Light