item
in the list. All the items that evaluate to the equal _group key_ are grouped together.key
in the formula to get the grouping key of the current group, and items
to access all the items belonging to the current group.GROUP(allProducts, item.category, { category: key, products: items })
[{"category":"Utility","products":[{"name":"Duct tape","category":"Utility"},{"name":"Glue","category":"Utility"}]},{"category":"Tools","products":[{"name":"Swiss army knife","category":"Tools"}]}]
GROUP(allProducts, item.category, key + " category contains " + COUNT(items) + " product(s)")
["Utility category contains 2 product(s)","Tools category contains 1 product(s)"]
GROUP<product, index, category, products>(allProducts, product.category, { category: category, count: COUNT(products) })
[{"category":"Utility","count":2},{"category":"Tools","count":1}]