arrayReplaceAt - Replaces element at specific position
arrayReplaceAt
will replace an element at a specific position and return the modified array.
Syntax
Like many functions in DataPrime, arrayReplaceAt
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
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 to replace the element in the array |
value | T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
Example - Cleaning up an old value in a list
Consider the following two documents:
We can see that there has been a schema change between NewVal1
and OldVal1
. To overcome this, we can use arrayReplaceAt
to replace the old schema with the new schema, before we continue processing.
This results in the following documents:
Theme
Light