Lime Web Components API Documentation - v7.4.0
    Preparing search index...

    Variable AggregateOperatorConst

    AggregateOperator: {
        Average: "AVG";
        Count: "COUNT";
        Group: "GROUP";
        Maximum: "MAX";
        Minimum: "MIN";
        Sum: "SUM";
    } = ...

    Aggregate operators for calculating summary statistics on object collections.

    The AggregateOperator object defines operators for aggregating numeric property values across multiple objects. These are used in queries to calculate totals, averages, counts, and min/max values.

    Available operators:

    • Group - Group the result by a property
    • Count - Count the number of objects
    • Sum - Sum all values
    • Average - Calculate mean value
    • Maximum - Find highest value
    • Minimum - Find lowest value

    Used in:

    Type Declaration

    • ReadonlyAverage: "AVG"

      Calculate average (mean) value of a numeric property.

      Computes the arithmetic mean of the property values across all matching objects.

    • ReadonlyCount: "COUNT"

      Count the number of objects.

      Returns the total count of objects matching the query filter.

    • ReadonlyGroup: "GROUP"

      Group the result by a property.

      Produces one response row per distinct value of the grouped property, instead of a single row for the whole result.

    • ReadonlyMaximum: "MAX"

      Find the maximum value of a numeric property.

      Returns the highest value found for the specified property among all matching objects.

    • ReadonlyMinimum: "MIN"

      Find the minimum value of a numeric property.

      Returns the lowest value found for the specified property among all matching objects.

    • ReadonlySum: "SUM"

      Sum all values of a numeric property.

      Calculates the sum of all values for the specified property across all matching objects.

    import {
    AggregateOperator,
    PlatformServiceName,
    Query,
    } from '@limetech/lime-web-components';

    const queryService = platform.get(PlatformServiceName.Query);

    const query = {
    limetype: 'deal',
    responseFormat: {
    aggregates: {
    totals: { total_count: { op: AggregateOperator.Count } },
    },
    },
    } satisfies Query;

    const response = await queryService.execute(query);
    const [totals] = response.aggregates.totals;

    console.log(`${totals?.total_count} deals`);
    import {
    AggregateOperator,
    Operator,
    PlatformServiceName,
    Query,
    } from '@limetech/lime-web-components';

    const queryService = platform.get(PlatformServiceName.Query);

    const query = {
    limetype: 'deal',
    filter: { key: 'status', op: Operator.EQUALS, exp: 'active' },
    responseFormat: {
    aggregates: {
    totals: {
    total_value: { op: AggregateOperator.Sum, key: 'value' },
    average_value: { op: AggregateOperator.Average, key: 'value' },
    },
    },
    },
    } satisfies Query;

    const response = await queryService.execute(query);

    const [totals] = response.aggregates.totals;
    console.log(totals?.total_value);
    console.log(totals?.average_value);
    import {
    AggregateOperator,
    PlatformServiceName,
    Query,
    } from '@limetech/lime-web-components';

    const queryService = platform.get(PlatformServiceName.Query);

    const query = {
    limetype: 'deal',
    responseFormat: {
    aggregates: {
    by_status: {
    status: { op: AggregateOperator.Group, key: 'dealstatus' },
    highest_deal: { op: AggregateOperator.Maximum, key: 'value' },
    lowest_deal: { op: AggregateOperator.Minimum, key: 'value' },
    },
    },
    },
    } satisfies Query;

    const response = await queryService.execute(query);

    for (const row of response.aggregates.by_status) {
    console.log(`${row.status}: ${row.lowest_deal} - ${row.highest_deal}`);
    }