Enumerations
Enums serve as a unique category of scalars that represent a predefined set of allowable values. They are particularly useful for data validation and ensuring type safety.
To utilize an
enum
, you need to specify the permissible values within the schema along with a designated name:enum Status {
PENDING_REVIEW
APPROVED
}
You can then use the
enum
for model fields:type Review @model {
status: Status
}
You can even set default values for enumerations:
type Review @model {
status: Status @default(value: PENDING_REVIEW)
}
Last modified 5mo ago