EloquentJS/My solution w/ abstract groupBy function