Skip to content

Interface: FieldDef<K, T, Req, Def> ​

Defined in: src/schema/field-types.ts:41

A compiled field definition. The last two type parameters carry the literal required/hasDefault flags so CreateInput can distinguish which keys are mandatory. When literals are widened to boolean, typing degrades gracefully to "everything optional" rather than producing false errors.

Type Parameters ​

K ​

K extends FieldKind = FieldKind

T ​

T = unknown

Req ​

Req extends boolean = boolean

Def ​

Def extends boolean = boolean

Properties ​

kind ​

kind: K

Defined in: src/schema/field-types.ts:47


required ​

required: Req

Defined in: src/schema/field-types.ts:48


hasDefault ​

hasDefault: Def

Defined in: src/schema/field-types.ts:49


default? ​

optional default?: Thunk<T>

Defined in: src/schema/field-types.ts:50


ref? ​

optional ref?: string

Defined in: src/schema/field-types.ts:56

Only set when kind === "ref": the referenced collection (supplies $lookup.from).


element? ​

optional element?: FieldDef<FieldKind, unknown, boolean, boolean>

Defined in: src/schema/field-types.ts:58

Only set when kind === "array": the element field.


schema? ​

optional schema?: SchemaDef

Defined in: src/schema/field-types.ts:60

Only set when kind === "embedded": the sub-schema.


choices? ​

optional choices?: readonly (string | number)[]

Defined in: src/schema/field-types.ts:62

Only set when kind === "enum": the allowed values.


unique? ​

optional unique?: boolean

Defined in: src/schema/field-types.ts:64

Create a unique index on this field (via ensureIndexes()).


index? ​

optional index?: boolean

Defined in: src/schema/field-types.ts:66

Create a (non-unique) index on this field (via ensureIndexes()).


_type? ​

readonly optional _type?: T

Defined in: src/schema/field-types.ts:68

Phantom carrier for inference. Never populated at runtime.

Methods ​

validate()? ​

optional validate(value): void

Defined in: src/schema/field-types.ts:54

Parameters ​

value ​

T

Returns ​

void

Released under the MIT License.