UNPKG

@forestadmin/datasource-toolkit

Version:
42 lines 1.34 kB
import Projection from './projection'; import { RecordData } from '../record'; export type AggregationOperation = 'Count' | 'Sum' | 'Avg' | 'Max' | 'Min'; export type DateOperation = 'Year' | 'Quarter' | 'Month' | 'Week' | 'Day'; export interface PlainAggregation { field?: string; operation: AggregationOperation; groups?: Array<{ field: string; operation?: DateOperation; }>; } type GenericAggregation = { field?: string; operation: AggregationOperation; groups?: Array<{ field: string; operation?: DateOperation; }>; }; export type AggregateResult = { value: unknown; group: RecordData; }; export default class Aggregation { field?: GenericAggregation['field']; operation: GenericAggregation['operation']; groups?: GenericAggregation['groups']; get projection(): Projection; constructor(components: GenericAggregation); apply(records: RecordData[], timezone: string, limit?: number): AggregateResult[]; nest(prefix: string): Aggregation; replaceFields(handler: (field: string) => string): Aggregation; private createSummaries; private formatSummaries; private createGroup; private createSummary; private updateSummaryInPlace; private applyDateOperation; } export {}; //# sourceMappingURL=aggregation.d.ts.map