arrayReplaceAll - Replaces all instances of a value with a new value
arrayReplaceAll
will replace all instances of a value in a given array with a new value.
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
array | array of type T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
value | T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
newValue | T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
Example - Cleaning up old values in lists
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 arrayReplaceAll
to replace the old schema with the new schema, before we continue processing.
This results in the following documents:
Theme
Light