Skip to content

in - Check if a value is equal to any of a number of values

The in function will compare a given value to a collection of other candidates. If the value matches one of the candidates, this function returns true, otherwise false.

Syntax

in(comparand: any, value: any, ...values: any): bool

Arguments

Name Type Required Description
comparand any true The keypath to be checked
value any true The first value to compare against comparand
...values any true All subsequent values to compare against comparand

Example - Check if team is in a department

Consider the following document:

{
    "team": "Developers"
},
{
    "team": "Marketing"
},
{
    "team": "QA Testing"
}

We can use the in command to see which of these teams are a member of the Engineering department:

create is_in_engineering from in(team, 'Developers', 'QA Testing', 'Front End Engineers', 'DevOps Team')

This will result in a document with a new field, is_in_engineering which is true if the value of team appears in the in function.

{
    "team": "Developers",
    "is_in_engineering": true
},
{
    "team": "Marketing",
    "is_in_engineering": false
},
{
    "team": "QA Testing",
    "is_in_engineering": true
}