Intro
Below is a comprehensive list of Array (Collection) data formatters available in App Connect (client-side), accompanied by explanations outlining the purpose and functionality of each.
Array Formatters
To Keyed Object:
- Converts an array into an object using a specified key and value expression.
- Example:
items.toKeyedObject('id', 'name')returns{1: 'Alice', 2: 'John'}
Has Items:
- Checks if the array contains any elements.
- Example:
items.hasItems()returnstrue
Contains:
- Checks if the array includes a specific value.
- Example:
items.contains(5)returnstrue
Join:
- Joins all array elements into a string using a separator.
- Example:
items.join(', ')returns'a, b, c'
Count:
- Returns the number of items in the array.
- Example:
items.count()returns3
Top:
- Returns the first N items of the array.
- Example:
items.top(2)returns the first two elements
Last:
- Returns the last item or last N items of the array.
- Example:
items.last()returns the last element - Example:
items.last(2)returns the last two elements
First:
- Returns the first item of the array.
- Example:
items.first()returns the first element
Get:
- Returns the item at the specified index.
- Example:
items.get(1)returns the second element
Slice:
- Returns a portion of the array between start and end indexes.
- Example:
items.slice(1, 3)returns a subset of the array
Reverse:
- Returns the array in reverse order.
- Example:
items.reverse()returns the reversed array
Randomize:
- Shuffles the array into a random order.
- Example:
items.randomize()returns a randomized array
Filter:
- Filters array items using a dynamic expression.
- Example:
items.filter('$value > 10')returns matching items
Map:
- Maps array items to a new array using an expression.
- Example:
items.map('$value.price')returns extracted values
Where:
- Filters objects by property, operator, and value.
- Example:
items.where('age', 30)returns matching items
Values:
- Extracts a specific property from each array item.
- Example:
items.values('name')returns['Alice', 'John']
Group By:
- Groups array objects by a specified property.
- Example:
items.groupBy('category')returns grouped object
Unique:
- Removes duplicate values (optionally by property).
- Example:
items.unique()returns unique values - Example:
items.unique('name')returns unique names
Sort:
- Sorts the array (optionally by property).
- Example:
items.sort('age')returns sorted items
Min:
- Returns the minimum value (or minimum property value).
- Example:
items.min('age')returns18
Max:
- Returns the maximum value (or maximum property value).
- Example:
items.max('age')returns65
Sum:
- Returns the sum of numeric values (or property values).
- Example:
items.sum('price')returns250
Avg:
- Returns the average of numeric values (or property values).
- Example:
items.avg('score')returns82.5