Skip to content

QueryIndex

Defined in: packages/core/src/access/types.ts:118

A concrete index a query will use: the output of resolveAccessIndex and, after arbitration, of pickQueryIndex. Both stages produce the same shape, so there is one type for both.

Distinct from what the user authors: a rule declares its index inside q.withIndex(name, (ix) => …), whose range is a function of the caller. Resolving one binds the caller in, leaving the plain (q) => … builder here and widening name to string — by resolve time the resource generic is gone. AccessIndex is the template; this is that template applied to one caller.

range is optional because after arbitration the winner may be a caller’s withIndex, and a caller may legitimately name an index with no range purely to order results. buildQuery already branches on this (api/find/server.tsrange ? withIndex(name, range) : withIndex(name)), so an absent range needs no placeholder.

An access-sourced index always carries one, guaranteed by AccessQueryBuilder.withIndex requiring its range callback rather than restated as a second type here — a range-less access index would scan the whole table, since every document has an index entry (fields that are missing are indexed as undefined).

name: string

Defined in: packages/core/src/access/types.ts:120

Index name to query.


optional range?: IndexRangeFn

Defined in: packages/core/src/access/types.ts:122

Range to apply; omitted for an ordering-only caller index.