ArraySetObjectValues Op
This op is deprecated!
It will not receive any updatesUpdates each object in an array with new data from a corresponding array, based on a specified key
Summary (oneliner)
This op takes an array of objects and updates each object's specified key with new data from a corresponding array of values. It supports deep updates using dot notation to specify the path to nested object properties. Error handling ensures keys are valid and do not reference non-existent paths or malformed strings. Users can choose to modify the original array directly or work on a copy of it. If an error is encountered, the operation returns null and logs detailed error information.
Nesting Key Feature
The nesting key feature allows users to specify keys using dot notation, which facilitates accessing and updating properties deep within nested objects. This is particularly useful for complex data structures.
Key Format: Dot notation should be used to specify the path to a nested property. For example, to update the
age
property inside a nestedprofile
object within auser
object, you would use the keyuser.profile.age
.Path Navigation: The operation parses the key string and traverses the object structure according to the segments of the key. Each segment of the key string corresponds to a level in the object's hierarchy.
Error Handling: If a specified path segment does not exist or is malformed (e.g., ends with a dot or contains empty segments due to consecutive dots), the operation logs an error and halts execution, ensuring data integrity by preventing incomplete or incorrect updates.
Example
// Assuming the operation is set up in cables.gl with the necessary ports:
inArr.set([{ user: { profile: { age: 25 }}}]);
inData.set([30]);
inKey.set("user.profile.age");
inCopy.set(false); // Directly modifies the original array
- Ops.Extension.Deprecated.ArraySetObjectValues
- Extension Op - Visible to all users
- MIT
Documentation (markdown)
Issues
Example patch id
Youtube ids (comma seperated)
Op Licence
Caniuse query
No op example found on this server
INPUT PORTS
Input port for the array of objects to be updated. Each object should be structured to accommodate updates based on the key provided.
Data array containing the new values to be set in each object. Each index in this array corresponds to the object at the same index in inArr.
The key at which to update the data in each object. Supports nested keys using dot notation (e.g., "data.value"). The key should not end with a dot or contain empty segments.
A boolean value determining whether to modify the original array (false) or to work on a copy of it (true). Default is false.
OUTPUT PORTS
Output port that emits the updated array of objects. This is either a reference to the modified original array or a new array, depending on the value of inCopy.