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?
optionaldefault?:Thunk<T>
Defined in: src/schema/field-types.ts:50
ref?
optionalref?:string
Defined in: src/schema/field-types.ts:56
Only set when kind === "ref": the referenced collection (supplies $lookup.from).
element?
optionalelement?:FieldDef<FieldKind,unknown,boolean,boolean>
Defined in: src/schema/field-types.ts:58
Only set when kind === "array": the element field.
schema?
optionalschema?:SchemaDef
Defined in: src/schema/field-types.ts:60
Only set when kind === "embedded": the sub-schema.
choices?
optionalchoices?: readonly (string|number)[]
Defined in: src/schema/field-types.ts:62
Only set when kind === "enum": the allowed values.
unique?
optionalunique?:boolean
Defined in: src/schema/field-types.ts:64
Create a unique index on this field (via ensureIndexes()).
index?
optionalindex?:boolean
Defined in: src/schema/field-types.ts:66
Create a (non-unique) index on this field (via ensureIndexes()).
_type?
readonlyoptional_type?:T
Defined in: src/schema/field-types.ts:68
Phantom carrier for inference. Never populated at runtime.
Methods
validate()?
optionalvalidate(value):void
Defined in: src/schema/field-types.ts:54
Parameters
value
T
Returns
void