index-by
$index-by
Groups an array of objects by a unique key, returning an object whose value is the single array element value that has that key. If the keys are not unique, throws an error.
{'$index-by': 'key'}— indexes by the named property on each element{'$index-by': processor}— indexes by the result of executing the processor against each element
Elements where the extracted key is undefined are omitted from the result.
Parameters
key(string): Property name to group by, or a processor that extracts the grouping key from each element. If you use a bare argument or a single element array, it is assumed to be the key.processor: Must be passed via object parameter. Must be a processor that will parse the provided element and return the index key. The outer collection is passed to the processor asoptions.input.
Example
// TODO