Array Types
> Store and manipulate lists of values with typed arrays.
An array in Brickr is an ordered list of values. Arrays are used when you need to work with multiple items: a list of users, a set of IDs, search results, or any collection of data.
Array type format
Array types use the format elementType:array. The element type tells you what kind of values the array contains.
| Array Type | Contains | Example | |-----------|----------|---------| | string:array | Text values | ["apple", "banana", "cherry"] | | number:array | Numeric values | [1, 2, 3, 42] | | boolean:array | True/false values | [true, false, true] | | object:array | Generic objects | [{...}, {...}] | | object:file:array | File objects | Array of file references | | any:array | Mixed values | Any combination |
Array pins are always port-only -- you cannot type an inline value for an array. You must connect a wire from another node's output.
Creating arrays
Make Array
The Make Array node creates an array from individual values.
- Add input pins for each element
- All inputs must be the same type
- The output is a typed array
From database queries
The DB Select node returns its results as an array of objects. Each row in the result set is one element in the array.
From string splitting
The Split string node breaks a string by a delimiter and returns a string:array.
Working with arrays
Common array nodes
| Node | Description | |------|-------------| | Array Length | Get the number of elements | | Get Element | Get an element by index | | Push | Add an element to the end | | Filter | Keep only elements matching a condition | | Map | Transform each element | | For Each | Execute a flow for each element | | Join | Convert a string array to a single string with a separator | | Sort | Sort elements | | Reverse | Reverse the order | | Includes | Check if an element exists in the array |
For Each
The For Each node is one of the most powerful array nodes. It loops through each element and executes a sub-flow for every item.
- Input: An array
- Outputs: The current element and the current index, available inside the loop body
- Sequence: Connect the loop body to define what happens for each element
Use For Each to process database results, send emails to a list of recipients, or transform a collection of items one by one.
Array type compatibility
Array types follow the same compatibility rules as their element types, with additional strictness:
| Output Type | Can connect to | |-------------|---------------| | string:array | string:array, any:array, any | | object:file:array | object:file:array, object:array, any:array, any |
A string:array cannot connect to a string input -- arrays and single values are distinct types.
Be careful with any:array -- it accepts arrays of any element type, but the nodes consuming its elements will not have type information. Use typed arrays whenever possible.
What's next?
| Topic | Description | |-------|-------------| | Objects | Object types and structures | | Primitives | String, number, boolean | | Enums | Named value sets |