Good day! Is there a way to either: 1. Export an E...
# orm-help
t
Good day! Is there a way to either: 1. Export an ENUM used as a field type on a model or 2. Import an ENUM defined somewhere in a file in the prisma scheme-a to use that enum as a field type Basically, I want to have access to enums I used as field types for my models elsewhere for additional typechecking
n
Hey Torrino 👋 Consider this model
Copy code
model Restaurant {
  id         Int                      @id @default(autoincrement())
  name       String
  slug       String
  image      String?
  categories CategoriesOnRestaurant[]
  createdAt  DateTime                 @default(now()) @map(name: "created_at")
  updatedAt  DateTime                 @updatedAt @map(name: "updated_at")
  disabled   Boolean                  @default(false)
  status     OrderStatus

  @@map("t_restaurant")
}

enum OrderStatus {
  PENDING
  CANCELED
  COMPLETED
  DELIVERED
}
Running
npx prisma generate
would export enum as a const
OrderStatus
like this:
Copy code
export const OrderStatus: {
  PENDING: 'PENDING',
  CANCELED: 'CANCELED',
  COMPLETED: 'COMPLETED',
  DELIVERED: 'DELIVERED'
};
And you can import them into your files through
@prisma/client
like this:
Copy code
import { OrderStatus } from '@prisma/client';
t
Thank you so much!