Skip to content

ConstraintsCallbackProps

ConstraintsCallbackProps<TData, TUser, TOrg, TQ> = object & [TOrg] extends [never] ? unknown : object

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

Props for a rule’s constraints callback: the caller, optionally the organization, and q — the builder the rule records onto. No data: constraints run once per query, before any document is read (contrast PermissionCallbackProps, which the sibling filter property uses).

q’s TYPE is what gates index pushdown per action (DD 14). A query-shaped action gets an AccessQueryBuilderfilter plus withIndex; every other action gets an AccessPredicateBuilder, the same shape minus withIndex, so a rule reads identically either way and q.withIndex is simply absent where there is no query to narrow. One property, two builder types, and nothing to discriminate at the object level.

q: TQ

user: TUser

TData = unknown

Document type constraints are typed against.

TUser = Record<string, unknown>

User document shape.

TOrg = Record<string, unknown>

Organization document shape; never if not configured.

TQ = AccessPredicateBuilder<TData>

The builder for this action: AccessQueryBuilder on query actions, AccessPredicateBuilder on mutations.