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

    Type Alias QueryResponse<Q>

    The shape of the response from executing a Query.

    Contains the objects that matched the query filter along with any requested aggregate calculations. Each aggregate group is returned as an array with one row per distinct combination of its GROUP columns, or a single row when the group has none.

    When the query's responseFormat is known at compile time (defined inline or with satisfies Query), the objects and aggregates shapes are inferred from it. Otherwise it falls back to unknown.

    Aggregate values are typed by operator: COUNT is number, SUM and AVG are number | null, and MIN and MAX are number | string | null (a date or text column returns a string, and an empty result returns null). A GROUP column returns the grouped property's value (a string, number, boolean, or null).

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

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

    const query = {
    limetype: 'deal',
    responseFormat: {
    object: { name: null, value: null },
    aggregates: {
    totals: {
    total_value: { op: AggregateOperator.Sum, key: 'value' },
    },
    },
    },
    } satisfies Query;

    const response = await queryService.execute(query);

    console.log(`Found ${response.objects.length} objects`);
    for (const deal of response.objects) {
    console.log(`Deal: ${deal.name}, Value: ${deal.value}`);
    }

    const [totals] = response.aggregates.totals;
    console.log(`Total value: ${totals?.total_value}`);
    type QueryResponse<Q extends Query = Query> = {
        aggregates: Q["responseFormat"] extends { aggregates: infer A }
            ? {
                -readonly [G in keyof A]: {
                    -readonly [C in keyof A[G]]: A[G][C] extends { op: "COUNT" }
                        ? number
                        : A[G][C] extends { op: "GROUP" }
                            ? string | number | boolean | null
                            : A[G][C] extends { op: "SUM"
                            | "AVG" }
                                ? number | null
                                : number | string | null
                }[]
            }
            : unknown;
        objects: Q["responseFormat"] extends { object: infer O }
            ? { -readonly [K in keyof O]: unknown }[]
            : unknown[];
    }

    Type Parameters

    Index

    Properties

    Properties

    aggregates: Q["responseFormat"] extends { aggregates: infer A }
        ? {
            -readonly [G in keyof A]: {
                -readonly [C in keyof A[G]]: A[G][C] extends { op: "COUNT" }
                    ? number
                    : A[G][C] extends { op: "GROUP" }
                        ? string | number | boolean | null
                        : A[G][C] extends { op: "SUM"
                        | "AVG" }
                            ? number | null
                            : number | string | null
            }[]
        }
        : unknown
    objects: Q["responseFormat"] extends { object: infer O }
        ? { -readonly [K in keyof O]: unknown }[]
        : unknown[]