Cerial
Enums

Overview

String-only named constants with filtering and ordering support.

Enums define a fixed set of string values. They generate an as const object, a union type, and a where type for filtering.

Definition

enum Role {
  Admin
  Editor
  Viewer
}

model User {
  id Record @id
  role Role @default(Viewer)
}

Generated Types

For an enum named Role, Cerial generates:

  • RoleEnumas const object: { Admin: 'Admin', Editor: 'Editor', Viewer: 'Viewer' }
  • RoleEnumType — Union type: 'Admin' | 'Editor' | 'Viewer'
  • RoleEnumWhere — Where type for filtering

Operations

OperationDescription
FilteringFilter by enum values using comparison operators
OrderBySort by enum fields (string ordering)

On this page