Skip to content

ConstraintBuilder

Defined in: packages/core/src/access/constraintTypes.ts:246

Position-tracking constraint builder — the type createConstraintBuilder (access/createConstraintBuilder.ts) returns, and what a rule’s constraints callback receives. eq pins the field at cursor N and advances to N + 1; gt/gte/lt/lte (inherited from LowerBoundConstraintBuilder) pin the SAME field and close the chain to further constraints. This encodes Convex’s complete index rule: zero or more eq, then at most one lower bound, then at most one upper bound, fields strictly in index order with no gaps, each value typed per field — violating any of these is a compile error, never a runtime one.

TFields extends readonly string[]

The index’s field tuple, in declaration order — typically IndexFieldsFor<slug, indexName> (types/generated.ts).

TDoc

Document shape constraint values are typed from.

N extends number = 0

The current field cursor. Defaults to 0, the index’s first field; only NextConstraintBuilder advances it.

eq<F>(field, value): NextConstraintBuilder<TFields, TDoc, N>

Defined in: packages/core/src/access/constraintTypes.ts:251

F extends string

F

ConstraintValue<TDoc, F>

NextConstraintBuilder<TFields, TDoc, N>


gt<F>(field, value): UpperBoundConstraintBuilder<TDoc, TFields[N]>

Defined in: packages/core/src/access/constraintTypes.ts:204

F extends string

F

ConstraintValue<TDoc, F>

UpperBoundConstraintBuilder<TDoc, TFields[N]>

LowerBoundConstraintBuilder.gt


gte<F>(field, value): UpperBoundConstraintBuilder<TDoc, TFields[N]>

Defined in: packages/core/src/access/constraintTypes.ts:208

F extends string

F

ConstraintValue<TDoc, F>

UpperBoundConstraintBuilder<TDoc, TFields[N]>

LowerBoundConstraintBuilder.gte


lt<F>(field, value): ConstraintResult

Defined in: packages/core/src/access/constraintTypes.ts:187

F extends string

F

ConstraintValue<TDoc, F>

ConstraintResult

LowerBoundConstraintBuilder.lt


lte<F>(field, value): ConstraintResult

Defined in: packages/core/src/access/constraintTypes.ts:188

F extends string

F

ConstraintValue<TDoc, F>

ConstraintResult

LowerBoundConstraintBuilder.lte