arrayIndexOf
Returns the index of a value inside an array.
The index is zero based, and if a value is not present in the array, it results in -1.
Arguments
- Array to use.
- Value to use.
Examples
Expression | Result |
---|---|
WITH $names = [ 'John Doe', 'Tom Cruise', 'David Bowie',null] SELECT { a = arrayIndexOf($names, 'Tom Cruise'), b = arrayIndexOf($names, null), c = arrayIndexOf($names, 'David Bowie') } | {"a": 1, "b": 3, "c": 2} |