How to: Use the Nest By and Table2Object Operators Together

Prev Next

Arrays are a great way to store large amounts of data. The Nest By operator lets you create a nested array in your parent array to group information by a particular key/value pair. In this example, you’ll nest data by an account number, where the account number key/value pair exists at the data structure's top level.

The account number exists as a value in the key/accountNumber pair. But you might want the account number to be the key instead of a value. Using a Table2Object operator, you'll convert your array of objects to an object. Each object in the source array of objects becomes a key/value pair in the final object. In this case, each key will be a unique account number. And the value will be the nested array associated with that account number.

Configuration

For this example, create a Data Table component that stores a list of customers, account values, and account numbers. Then, set up a Data Workflow component and convert your array of objects to an object. Each object in the source array of objects becomes a key/value pair in the final object. In this case, each key will be a unique account number, and the value will be the nested array associated with that account number. A Hidden component is added to store your Data Workflow's output.

Configure the Data Table Component

First, you'll set up a Data Table component with a list of customers, account values, and account numbers.

  1. In the Module Builder, drag and drop a Data Table component onto your canvas.

  2. In the Property ID fields, enter dtAccountInfo.

  3. In the data table, enter the following:

    accountNumber

    firstName

    lastName

    accountValue

    12345

    Josephine

    Darakjy

    543891

    12346

    Lenna

    Paprocki

    1000000

    12346

    Sage

    Wieser

    1000000

    12347

    Abel

    Maclead

    7432572

    12348

    Ernie

    Stenseth

    5000000

    12349

    Valentine

    Gillian

    5439294

    12346

    Dyan

    Oldroyd

    17890

    12347

    Fatima

    Saylors

    19578

    12347

    Willow

    Kusko

    54389

    You purposely added duplicate information to show the power of the Nest By operator.

    Data table displaying account numbers, names, and account values for various individuals.

  4. Click Save Component.

Configure the Hidden Component

Now, add a Hidden component to store your Data Workflow's output.

  1. Drag and drop a Hidden component onto your canvas, placing it below your Data Table component.

  2. In the Property ID and Label Text fields, enter output.

  3. Click Save Component.

Configure the Button Component

Next, add a Button component to trigger your Data Workflow component.

  1. Drag and drop a Button component onto your canvas, placing it below your output Hidden component.

  2. In the Property ID field, enter btnNestToObject.

  3. In the Label Text field, enter Nest to Object.

  4. From the Action Type drop-down, select Event.

  5. In the On Click field, enter dwfNestToObject.

    Button configuration showing label text and action triggers for event handling.

  6. Click Save Component.

Configure the Data Workflow Component

Lastly, you’ll add a Data Workflow component to convert your array of objects to an object.

  1. Drag and drop a Data Workflow component onto your canvas, placing it below your btnNestToObject Button component.

  2. In the Property ID and Canvas Label Text fields, enter dwfNestToObject.

Configure the Input Operator

  1. Drag and drop an Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    dtAccountInfo

    Required

    No

    Source

    Default

Configure the Nest By Operator

  1. Drag and drop a Nest By operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Nest By

    Label

    accountNumber

    Parent Keys

    accountNumber

    Child Name

    account

  3. Connect the output port (right) of the dtAccountInfo Input operator to the input port (left) of the accountNumber Nest By operator.

Configure the Table2Object Operator

  1. Drag and drop a Table2Object operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Table2Object

    Label

    Nest to Object

    Key Column Name

    accountNumber

    Value Column Name

    account

  3. Connect the output port (right) of the accountNumber Nest By operator to the input port (left) of the Nest to Object Table2Object operator.

Configure the Output Operator

  1. Drag and drop an Output operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Output

    Component

    output

    Action

    value

  3. Connect the output port (right) of the Nest to Object  Table2Object operator to the input (left) port of the output  Output operator.

Configure the First Console Operator

  1. Drag and drop another Console operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Console

    Label

    After Nest By

  3. Connect the output port (right) of the accountNumber  Nest By operator to the input port (left) of the After Nest By Console operator.

  4. Click Save Component.

Configure the Second Console Operator

  1. Drag and drop another Console operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Console

    Label

    After Table2Object

  3. Connect the output port (right) of the Nest to Object Table2Object operator to the input port (left) of the After Table2Object Console operator.

    Data workflow diagram illustrating input, nesting, and output processes for account information.

  4. Click Save Component.

  5. Save your module.

Here's how your module looks in the Module Builder:Interface displaying account information and options for nesting objects in a system.

Preview your module in Express View and open the DevTools Console. Click the Nest to Object button, and you'll see your data grouped by account number in the After Nest By Console operator. In the After Table2Object Console operator, you'll see that each account number is now an array of objects. Expand a tab and you'll see the array(s) inside each object.

Console output showing account details and nested object structure in Unqork application.

Arrays are a great way to store large amounts of data. The Nest By operator lets you create a nested array in your parent array to group information by a particular key/value pair. In this example, you’ll nest data by an account number, where the account number key/value pair exists at the data structure's top level.

The account number exists as a value in the key/accountNumber pair. But you might want the account number to be the key instead of a value. Using a Table2Object operator, you'll convert your array of objects to an object. Each object in the source array of objects becomes a key/value pair in the final object. In this case, each key will be a unique account number. And the value will be the nested array associated with that account number.

Configuration

For this example, create a Data Table component that stores a list of customers, account values, and account numbers. Then, set up a Data Workflow component and convert your array of objects to an object. Each object in the source array of objects becomes a key/value pair in the final object. In this case, each key will be a unique account number, and the value will be the nested array associated with that account number. A Hidden component is added to store your Data Workflow's output.

Configure the Data Table Component

First, you'll set up a Data Table component with a list of customers, account values, and account numbers.

  1. In the Module Builder, drag and drop a Data Table component onto your canvas.

  2. In the Label and Property Name fields, enter dtAccountInfo.

  3. In the data table, enter the following:

    accountNumber

    firstName

    lastName

    accountValue

    12345

    Josephine

    Darakjy

    543891

    12346

    Lenna

    Paprocki

    1000000

    12346

    Sage

    Wieser

    1000000

    12347

    Abel

    Maclead

    7432572

    12348

    Ernie

    Stenseth

    5000000

    12349

    Valentine

    Gillian

    5439294

    12346

    Dyan

    Oldroyd

    17890

    12347

    Fatima

    Saylors

    19578

    12347

    Willow

    Kusko

    54389

    You purposely added duplicate information to show the power of the Nest By operator.

    Data table displaying account information with account numbers, names, and values listed.

  4. Click Save.

Configure the Hidden Component

Now, let's add a Hidden component to store your Data Workflow's output.

  1. Drag and drop a Hidden component onto your canvas, placing it below your Data Table component.

  2. In the Property ID and Canvas Label Text fields, enter output.

  3. Click Save.

Configure the Button Component

Next, add a Button component to trigger your Data Workflow component.

  1. Drag and drop a Button component onto your canvas, placing it below your output Hidden component.

  2. In the Property ID field, enter btnNestToObject.

  3. In the Label Text field, enter Nest to Object.

  4. Set the Action Type as Event.

  5. In the On Click field, enter dwfNestToObject.

    Button configuration with action types and triggers for event handling in a workflow.

  6. Click Save & Close.

Configure the Data Workflow Component

Lastly, you’ll add a Data Workflow component to convert your array of objects to an object.

  1. Drag and drop a Data Workflow component onto your canvas, placing it below your btnNestToObject Button component.

  2. In the Canvas Label Text and Property Name fields, enter dwfNestToObject.

Configure the Input Operator

  1. Drag and drop an Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    dtAccountInfo

    Required

    No

    Source

    Default

Configure the Nest By Operator

  1. Drag and drop a Nest By operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Nest By

    Label

    accountNumber

    Parent Keys

    accountNumber

    Child Name

    account

  3. Connect the output port (right) of the dtAccountInfo Input operator to the input port (left) of the accountNumber Nest By operator.

Configure the Table2Object Operator

  1. Drag and drop a Table2Object operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Table2Object

    Label

    Nest to Object

    Key Column Name

    accountNumber

    Value Column Name

    account

  3. Connect the output port (right) of the accountNumber Nest By operator to the input port (left) of the Nest to Object Table2Object operator.

Configure the Output Operator

  1. Drag and drop an Output operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Output

    Component

    output

    Action

    value

  3. Connect the output port (right) of the Nest to Object Table2Object operator to the input (left) port of the output Output operator.

Configure the First Console Operator

  1. Drag and drop another Console operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Console

    Label

    After Nest By

  3. Connect the output port (right) of the accountNumber Nest By operator to the input port (left) of the After Nest By Console operator.

Configure the Second Console Operator

  1. Drag and drop another Console operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Console

    Label

    After Table2Object

  3. Connect the output port (right) of the Nest to Object Table2Object operator to the input port (left) of the After Table2Object Console operator.

    Data workflow diagram showing input, output, and console elements for processing data.

  4. Click Save.

  5. Save your module.

Here's how your module looks in the Module Builder:

Interface showing account information and options for user interaction and navigation.

Preview your module in Express View and open the DevTools Console. Click the Nest to Object button, and you'll see your data grouped by account number in the After Nest By Console operator. In the After Table2Object Console operator, you'll see that each account number is now an array of objects. Expand a tab and you'll see the array(s) inside each object.

Console output showing account details and nested arrays in Unqork application.