Type Alias InferQueryResults<T, F, SK>

InferQueryResults: ExtractTypeFromFilter<F> extends infer Names
    ? ShouldNarrow<T, Names> extends true
        ? IntersectTypeWithOr<T, F>
        : FallbackToFilterKeys<T, F, SK>
    : FallbackToFilterKeys<T, F, SK>

Infers query results from filter and SK for the non-index query overload.

Narrowing strategy (respects DynamoDB's AND semantics):

  1. If the filter specifies a top-level type value, narrow by that — then intersect with $or narrowing if present (since DynamoDB ANDs them).
  2. Otherwise, if top-level filter keys narrow to specific entities, use that — then intersect with $or narrowing if present.
  3. Otherwise, if $or blocks resolve to specific entities (by type or keys), use that.
  4. Otherwise, if skCondition matches an exact entity name or $beginsWith an entity name, narrow by that.
  5. Otherwise, return the full QueryResults<T> union.

When both top-level (type or keys) and $or narrow to different entity sets, the intersection is taken. An empty intersection produces never[], reflecting that no DynamoDB record can satisfy both AND-combined conditions.

Type Parameters

  • T extends default

    The root entity being queried.

  • F

    The inferred filter type (captured via const generic).

  • SK = unknown

    The inferred sort key condition type.