Enums
Creating a Postgres Enumerated Type in your schema will add this data type to your enums directory.
CREATE TYPE penguin_flight_attempt_method AS ENUM ( 'glider', 'ski_jump', 'jet_pack', 'catapult', 'trampoline', 'rocket', 'giant_sling', 'balloon');Directoryno-orm
Directorypublic
Directoryenums
- schemas.ts
- types.ts
This generates a Zod schema which can parse the enum from your database:
export const penguinFlightAttemptMethod = z.union([ z.literal("glider"), z.literal("ski_jump"), z.literal("jet_pack"), z.literal("catapult"), z.literal("trampoline"), z.literal("rocket"), z.literal("giant_sling"), z.literal("balloon"),]);import * as Schemas from "./schemas";
export type PenguinFlightAttemptMethod = z.infer< typeof Schemas.penguinFlightAttemptMethod>;Note that enums are scoped on a per-schema level (e.g public).