inArray
The inArray
function checks whether a given element exists within an array. It returns true
if the array contains a matching element, and false
if it does not. This function is the inverse of arrayContains
.
Syntax
Like all functions in DataPrime, inArray
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Function notation | Method notation |
---|---|
Arguments
Name | Type | Required | Description |
---|---|---|---|
element | T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
array | array of type T | true | Must be an array where each element is of the same type T as defined in the element field (i.e., one of: string , bool , number , interval , timestamp , regexp , or enum ). |
Example - Check if a particular IP appears in a block list
Consider the following log, from a router:
We can check if client_ip exists in an array of ip addresses.
Function notation
Method notation
Result
The query will return true
since the IP address 192.168.1.105
is in the provided array.
Theme
Light