| 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// Standard property definition
2@Field.Prop(() => Type, { ...options })
3propertyName: TypeScriptType;
4
5// Example with validation
6@Field.Prop(() => Int, { min: 0, max: 100 })
7score: number;
8 1@Field.Prop(() => String, { minlength: 3, maxlength: 50 })
2username: string;
3
4@Field.Prop(() => Boolean, { default: false })
5isActive: boolean;
6 1@Field.Resolve(() => String)
2get fullName(): string {
3 return `${this.firstName} ${this.lastName}`;
4}
5 | 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" }1export const Status = enumOf(["active", "inactive"] as const);
2export type Status = enumOf<typeof Status>;
3
4@Field.Prop(() => String, { enum: Status, default: "active" })
5status: Status;
6 1// Single reference
2@Field.Prop(() => LightUser, { ref: "User" })
3owner: LightUser;
4
5// Dynamic reference
6@Field.Prop(() => LightModel, { refPath: "modelType" })
7model: LightModel;
8 1// Built-in validation
2@Field.Prop(() => String, { minlength: 8, maxlength: 100 })
3password: string;
4
5// Custom validation
6@Field.Prop(() => String, {
7 validate: (value) => /^[A-Z][a-z]+$/.test(value)
8})
9properName: string;
10 Check if using Field.Hidden instead of Field.Prop
Ensure default value type matches field type
Add { text: 'search' } option to searchable fields