GroupBy icon

GroupBy

Groups items by a key, optionally as stream items or as an object with an array of items

GroupBy

AI-generated

Overview

This node groups input items by a specified key, allowing users to organize data based on a property value. It supports grouping by nested properties using dot notation and offers multiple output formats to suit different use cases. Common scenarios include aggregating data by user ID, category, or any other property to facilitate further processing or analysis.

Use Case Examples

  1. Grouping a list of user records by their 'user.id' to process each user's data separately.
  2. Organizing transaction records by 'transaction.type' to generate reports per transaction type.

Properties

Name Meaning
Key to Group By Property to pull the value used for grouping. Supports dot notation (e.g., 'user.key').
Output Format Determines the structure of the output data after grouping.
Disable Dot Notation Whether to disallow referencing child fields using 'parent.child' in the field name.

Output

JSON

  • items - Array of grouped items for each group (used in stream elements and object entries formats).
  • key - The key value used for grouping (present in stream elements output).
  • index - Index of the group in the output stream (present in stream elements output).

Dependencies

  • lodash/get for safely accessing nested properties

Troubleshooting

  • If the key to group by does not exist in some items, those items will be grouped under the string 'undefined'. Ensure the key is correct and exists in all items.
  • If an unknown output format is specified, the node throws an error indicating the invalid format. Verify the output format parameter.

Discussion