GroupByField
cartographer / groupByField
Function: groupByField()
Section titled “Function: groupByField()”groupByField(
items,fieldKey):Map<unknown,CatalogItem[]>
Defined in: queries/queryFunctions.ts:422
Group items by a field value.
Each unique field value gets its own group. Items with the same field value appear together.
Parameters
Section titled “Parameters”Array of items to group
fieldKey
Section titled “fieldKey”string
Field key to group by
Returns
Section titled “Returns”Map<unknown, CatalogItem[]>
- Map of field values to arrays of items with that value
Example
Section titled “Example”const byStatus = groupByField(items, 'catalog-status');// { 'raw': [item1, item2], 'approved': [item3, item4] }