Enumeration Definition
Basic Structure
enumeration:
EnumName:
meta: enum @db(field) @json(field)
fields:
field1: type [annotations]
field2: type [annotations]
enum:
VALUE1: code1,label1
VALUE2: code2,label2
Meta Annotations
@db(fieldName): Specify the field used for database storage@json(fieldName): Specify the field used for JSON serialization
Field Annotations
@length(n): String length limit@code: Designate the field for database storage and JSON serialization
Enum Values Definition
- Define values in the order corresponding to the fields defined in the field definition section
Enumeration Examples
enumeration:
BoardType:
meta: enum @db(code) @json(code)
fields:
code: string(2) @length(3) -- Type code
name: string(50) -- Name
enum:
PUBLIC: PB,Public
PRIVATE: PV,Private
NOTICE: NT,Notice
UserStatus:
meta: enum
fields:
status: string(1) @code
description: string(20)
enum:
ACTIVE: A,Active
INACTIVE: I,Inactive
SUSPENDED: S,Suspended
Naming Conventions
Enumerations
- Class name: PascalCase + descriptive suffix (BoardType, UserStatus)
- Constant name: UPPER_CASE (PUBLIC, PRIVATE, ACTIVE)