BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
50 / 278 · Module 3 — DataWeave 2.0 Crash Course · filtered: code← prev⊞ allnext →

3.26`groupBy`

Imagine orders:

[
  {"customerId": "A", "amount": 10},
  {"customerId": "B", "amount": 20},
  {"customerId": "A", "amount": 30}
]

You can group:

payload groupBy $.customerId

Conceptually:

{
  "A": [
    {"customerId": "A", "amount": 10},
    {"customerId": "A", "amount": 30}
  ],
  "B": [
    {"customerId": "B", "amount": 20}
  ]
}

Very useful for integration aggregation.