arrayInsertAt - Add element at specified position in array
arrayInsertAt
will add an element at a given position
.
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
array | array of type T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
position | number | true | The index at which an element should be inserted |
value | T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
Example - Adding a job in the middle of a queue
Consider the following document:
Inserting an item in a given point in an array is as simple as:
This results in the following document:
Try it yourself
Open up your explore screen and enter the following command:
create values from ['Job 1', 'Job 2', 'Job 4']
| create updated_values from values.arrayInsertAt(2, 'Job 3')
Theme
Light