| decorator | Description | Example |
|---|---|---|
| Field.Prop | Standard visible property stored in DB and exposed in API | |
| Field.Hidden | Internal data stored in DB but not exposed in API | |
| Field.Secret | Sensitive data with restricted access | |
| Field.Resolve | Computed property calculated at runtime | |
Standard visible property stored in DB and exposed in API
1@Field.Prop(() => String)Internal data stored in DB but not exposed in API
1@Field.Hidden(() => String)Sensitive data with restricted access
1@Field.Secret(() => String)Computed property calculated at runtime
1@Field.Resolve(() => Int)1
2// Standard property definition
3@Field.Prop(() => Type, { ...options })
4propertyName: TypeScriptType;
5
6// Example with validation
7@Field.Prop(() => Int, { min: 0, max: 100 })
8score: number;
9 1
2@Field.Prop(() => String, { minlength: 3, maxlength: 50 })
3username: string;
4
5@Field.Prop(() => Boolean, { default: false })
6isActive: boolean;
7 1
2@Field.Resolve(() => String)
3get fullName(): string {
4 return `${this.firstName} ${this.lastName}`;
5}
6 | Option | Type | Default | Description | Example |
|---|---|---|---|---|
| default | any | null | Default value for the field | |
| nullable | boolean | false | Allows null values | |
| enum | Enum | - | Restricts to specific enum values | |
| immutable | boolean | false | Prevents modification after creation | |
| min/max | number | - | Value range constraints | |
| ref | string | - | Reference to another model | |
| text | "search" | "filter" | - | Search indexing behavior | |
Default value for the field
1{ default: "active" }Allows null values
1{ nullable: true }Restricts to specific enum values
1{ enum: StatusEnum }Prevents modification after creation
1{ immutable: true }Value range constraints
1{ min: 0, max: 100 }Reference to another model
1{ ref: "User" }Search indexing behavior
1{ text: "search" }1
2export const Status = enumOf(["active", "inactive"] as const);
3export type Status = enumOf<typeof Status>;
4
5@Field.Prop(() => String, { enum: Status, default: "active" })
6status: Status;
7 1
2// Single reference
3@Field.Prop(() => LightUser, { ref: "User" })
4owner: LightUser;
5
6// Dynamic reference
7@Field.Prop(() => LightModel, { refPath: "modelType" })
8model: LightModel;
9 1
2// Built-in validation
3@Field.Prop(() => String, { minlength: 8, maxlength: 100 })
4password: string;
5
6// Custom validation
7@Field.Prop(() => String, {
8 validate: (value) => /^[A-Z][a-z]+$/.test(value)
9})
10properName: string;
11 Check if using Field.Hidden instead of Field.Prop
Ensure default value type matches field type
Add { text: 'search' } option to searchable fields