field
field<
TYPE>(type,options?):FieldValue<TYPE>
Defined in: .work/repos/edinburgh/src/models.ts:52
Create a field definition for a model property.
This function uses TypeScript magic to return the field configuration object while appearing to return the actual field value type to the type system. This allows for both runtime introspection and compile-time type safety.
Type Parameters
Section titled “Type Parameters”TYPE extends TypeWrapper<any>
Parameters
Section titled “Parameters”TYPE
The type wrapper for this field.
options?
Section titled “options?”Partial<FieldConfig<FieldValue<TYPE>>> = {}
Additional field configuration options.
Returns
Section titled “Returns”FieldValue<TYPE>
The field value (typed as T, but actually returns FieldConfig
Example
Section titled “Example”const User = E.defineModel("User", class { name = E.field(E.string, {description: "User's full name"}); age = E.field(E.opt(E.number), {description: "User's age", default: 25});});