Skip to content

isSuperset - Check if one array contains another array

isSuperset returns true if array1 is a superset 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

isSuperset(array1: array<T>, array2: array<T>): bool

Arguments

NameTypeRequiredDescription
array1array of type TtrueT must be either string, bool, number, interval, timestamp, regexp or enum
array2array of type TtrueT must be either string, bool, number, interval, timestamp, regexp or enum

Example - Basic usage

Consider the following document:

{
    "all_jobs": ["Chris", "John", "Adam", "Ariel", "Zev"],
    "started_jobs": ["Chris", "John"]
}

If we wish to check that all_jobs is a superset of started_jobs, we can do the following:

create is_superset from all_jobs.isSuperset(started_jobs)

This results in the following document:

{
    "all_jobs": ["Chris", "John", "Adam", "Ariel", "Zev"],
    "started_jobs": ["Chris", "John"],
    "is_superset": true
}