Enumerations

Enums are a special type of scalar that are a set of allowed values which is great for data validation and type-safety.

To use an enum you must define the possible values in the schema as well as a 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)
}
Was this page helpful?