The entity the decorator is applied to.
The type of the attribute, restricted to the values listed in values
prop of EnumAttributeOptions
An optional object of EnumAttributeOptions, including the allowed values, configuration options such as metadata attributes and additional property characteristics.
A class field decorator function that targets and initializes the class's prototype to register the attribute with the ORM's metadata system, ensuring proper handling and validation of the entity's enum values.
Usage example:
class Product extends TableClass {
@EnumAttribute({ alias: 'SomeField', values: ["val-1", "val-2"] })
public someField: "val-1" | "val-2"; // Attribute representing the union/enum types specified in `values`. In this case the only allowed values are "val-1" and "val-2"
@EnumAttribute({ alias: 'MyNullableField', nullable: true, values: ["val-1", "val-2"] })
public myNullableField?: "val-1" | "val-2"; // Set to Optional for nullable attributes
}
Generated using TypeDoc
A decorator for marking class fields as enum attributes within the context of a single-table design entity. Only the types specified in
values
are allowed via both the type system and runtime schema checks.This enforces a union type of the specified fields listed in
values