dyna-record
    Preparing search index...

    Type Alias SKScopedFilterParams<T, SK>

    SKScopedFilterParams: ExtractEntityFromSK<T, SK> extends infer Names
        ? ShouldNarrow<T, Names> extends true
            ? FilterParamsForEntities<ResolveEntityByName<T, Names & string>>
            : TypedFilterParams<T>
        : TypedFilterParams<T>

    Computes the filter type based on SK narrowing. When skCondition narrows to specific entities, only those entities' attributes are accepted in the filter. When SK doesn't narrow (no skCondition, suffixed string, etc.), falls back to the full TypedFilterParams. See ExtractEntityFromSK for which sort key conditions narrow.

    Use it to type a reusable filter for a query whose skCondition names an entity, passing the same sort key condition. A partition-wide TypedFilterParams is refused beside such an skCondition, because it also offers other entities' keys and type values that cannot match the rows the sort key selects.

    Type Parameters

    • T extends default

      The root entity being queried.

    • SK

      The inferred sort key condition type.

    async function ordersFor(
    customerId: string,
    filter: SKScopedFilterParams<Customer, "Order">
    ) {
    // Array<EntityAttributesInstance<Order>>
    return await Customer.query(customerId, { skCondition: "Order", filter });
    }

    await ordersFor("123", { orderDate: { $gte: new Date("2026-01-01") } });

    // A filter scoped to Order cannot name a ContactInformation attribute
    await ordersFor("123", { email: "jane@example.com" }); // Compile error