import {EnforceNonEmptyRecord, ValueRecord} from '../../record' import {AggregatableTable} from '../aggregatable_table' import {aggregateGroups, SelectRows} from '../selection/select_rows' import {SortGroupingOfThreeTables} from './sort_grouping_of_three_tables' import { addAscendingGroupOrder, addDescendingGroupOrder, GroupSelectStatement } from '../../statements/group_select_statement' import {Value} from '../../value' export class GroupThreeTables { constructor(private readonly statement: GroupSelectStatement) {} sortBy(sortBy: (key: K, first: AggregatableTable, second: AggregatableTable, third: AggregatableTable, count: () => number) => Value): SortGroupingOfThreeTables { return new SortGroupingOfThreeTables(addAscendingGroupOrder(this.statement, sortBy)) } sortDescendinglyBy(sortBy: (key: K, first: AggregatableTable, second: AggregatableTable, third: AggregatableTable, count: () => number) => Value): SortGroupingOfThreeTables { return new SortGroupingOfThreeTables(addDescendingGroupOrder(this.statement, sortBy)) } aggregate( aggregation: (key: K, first: AggregatableTable, second: AggregatableTable, third: AggregatableTable) => EnforceNonEmptyRecord & A): SelectRows { return aggregateGroups(this.statement, aggregation) } }