ArraySetObjectValues Op

ArraySetObjectValues

This op is deprecated!

It will not receive any updates

Updates each object in an array with new data from a corresponding array, based on a specified key


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 nested profile object within a user object, you would use the key user.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

Full Name
  • Ops.Extension.Deprecated.ArraySetObjectValues
Visibility
  •  Extension Op - Visible to all users
License
  • MIT
AuthorgithubMaintained by Team








No op example found on this server

INPUT PORTS


Array of objects (Array)

Input port for the array of objects to be updated. Each object should be structured to accommodate updates based on the key provided.

Data per object (Array)

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.

Key in each object (String)

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.

Copy Array (Number:boolean )

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


Updated array (Array)

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.


Patches using ArraySetObjectValues

  • Examples
  • Public
  • My Patches

Changelog


new opop createduser avatarkikohs - 2024-05-17 12:12