You can access the user_type enum in your application code like this:

import {user_type } from "@prisma/client";

let foo: user_type = "superadmin";
// use like any other type/enum

How you plan to connect this to the client-side or send it there is up to you. Typically Prisma types reside in the server-side of your code, not the client-side, so it might be difficult to import prisma types in your client code directly.

This is how Prisma defines the user_type enum under the hood.

// file: node_modules/.prisma/client/index.d.ts
export const user_type: {
  superadmin: 'superadmin',
  admin: 'admin',
  user: 'user'
};

You could just copy and paste this into your client-side code if you like.

Answer from Tasin Ishmam on Stack Overflow
🌐
Prisma
prisma.io › home › models › models › models › models
Models | Prisma Documentation
@map and @@map allow you to tune the shape of your Prisma Client API by decoupling model and field names from table and column names in the underlying database. The properties of a model are called fields, which consist of: ... Scalar types (includes enums) that map to columns (relational databases) or document fields (MongoDB) - for example, String or Int
Discussions

Specify value for Enum
Problem I want to add a custom value to my Enum types so I can easily provide my FE the key/value pairs for Enum types. My goal is to define an enum like this: enum AlarmTypes { FIRE_ALARM @value("... More on github.com
🌐 github.com
3
March 17, 2022
Enum with custom value
enum FileType { IMAGE_JPEG = "image/jpeg", IMAGE_PNG = "image/png" } PrismaJoinThe official Discord server of Prisma! More on answeroverflow.com
🌐 answeroverflow.com
January 31, 2025
Missing generated Enum in typescript definition when Enum isn't used in Prisma table
Bug description Normally, you can simply import Prisma enums as a typescript type like below: import type { MyEnum } from "@prisma/client" However, if the Enum isn't used in any Prism... More on github.com
🌐 github.com
3
June 12, 2024
Recommended Enum usage with Prisma and Zod
interface ItemRequestTableProps { statusFilter: ItemRequestStatusType; } I've started wondering if I should remove the Zod enum/type and simply reference the ItemRequestStatus enum generated by Prisma. More on answeroverflow.com
🌐 answeroverflow.com
June 11, 2025
🌐
Squash
squash.io › tutorial-on-prisma-enum-with-typescript
Tutorial on Prisma Enum with TypeScript - Squash Labs
October 14, 2023 - These generated types provide a ... at compile-time. Enum types in TypeScript can be used in conjunction with Prisma to define and enforce restricted sets of values for certain fields in your database schema....
🌐
Medium
medium.com › @sahiljaggrwal › clean-code-with-prisma-how-to-organize-your-schema-like-a-pro-5e1360a19dae
Organizing Prisma Schema: Splitting Models, Enums, and Types into Separate Files | by sahil jaggarwal | Medium
April 11, 2025 - // enums/role.enum.prisma enum Role { USER ADMIN MODERATOR } // models/user.model.prisma: model User { id String @id @default(auto()) @map("_id") @db.ObjectId name String email String @unique role Role } // types/profile.type.prisma type Profile { bio String website String }
🌐
GitHub
github.com › prisma › prisma › issues › 12405
Specify value for Enum · Issue #12405 · prisma/prisma
March 17, 2022 - Problem I want to add a custom value to my Enum types so I can easily provide my FE the key/value pairs for Enum types. My goal is to define an enum like this: enum AlarmTypes { FIRE_ALARM @value("Fire alarm ringing") @map("FIRE") SMOKE_...
Author   prisma
🌐
Prisma
prisma.io › home › overview of prisma schema › overview of prisma schema › overview of prisma schema
Prisma schema | Prisma Documentation
datasource db { provider = "postgresql" } generator client { provider = "prisma-client" output = "./generated" } model User { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) email String @unique name String? role Role @default(USER) posts Post[] } model Post { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt published Boolean @default(false) title String @db.VarChar(255) author User @relation(fields: [authorId], references: [id]) authorId Int } enum Role { USER ADMIN } Prisma Schema files are written in Prisma Schema Language (PSL).
🌐
GitHub
github.com › prisma › prisma › discussions › 26084
Using Enums · prisma/prisma · Discussion #26084
Changing the schema from an enum to a text type in your Prisma model can be a practical solution if you're encountering issues with enum handling. By using a text type, you avoid potential mismatches between the Prisma enum and the PostgreSQL enum.
Author   prisma
🌐
Medium
medium.com › @kemaltf_ › what-is-schema-in-prisma-1f52ddac630e
What is schema in prisma.. Attention: | by Taufik Kemal | Medium
June 23, 2023 - In Prisma, an “enum” is short for “enumeration” and is a special data type that restricts the values that can be taken by a column in a database.
Find elsewhere
🌐
Prisma
prisma.io › home › schema api › schema api › schema api
Prisma Schema API | Prisma Documentation
Maps a field name or enum value from the Prisma schema to a column or document field with a different name in the database.
🌐
Answer Overflow
answeroverflow.com › m › 1334838010537185371
Enum with custom value - Prisma
January 31, 2025 - enum FileType { IMAGE_JPEG = "image/jpeg", IMAGE_PNG = "image/png" } PrismaJoinThe official Discord server of Prisma!
🌐
GitHub
github.com › prisma › prisma › issues › 24510
Missing generated Enum in typescript definition when Enum isn't used in Prisma table · Issue #24510 · prisma/prisma
June 12, 2024 - Bug description Normally, you can simply import Prisma enums as a typescript type like below: import type { MyEnum } from "@prisma/client" However, if the Enum isn't used in any Prisma table column, Prisma doesn't generate the typescript...
Author   prisma
🌐
Dodatech
tutorials.dodatech.com › home › backend development › prisma › prisma enums
Learn Prisma Enums -- Enum Types in Schema and Queries – DodaTech Tutorials
1 month ago - Implement Prisma enums for type-safe fields, enum values in filters and updates, database-level enum support, and migrating enum changes.
🌐
Answer Overflow
answeroverflow.com › m › 1382210489408426037
Recommended Enum usage with Prisma and Zod
June 11, 2025 - interface ItemRequestTableProps { statusFilter: ItemRequestStatusType; } I've started wondering if I should remove the Zod enum/type and simply reference the ItemRequestStatus enum generated by Prisma.
🌐
RedwoodJS Community
community.redwoodjs.com › get help and help others › show & tell
How to Make SelectFields for Prisma enums in RedwoodJS - Show & Tell - RedwoodJS Community
October 6, 2022 - How to Make SelectFields for Prisma enums in RedwoodJS 👉 Demo: https://rw-office-hours-enum-select-list.netlify.app 👉 GH Repo: [redwood-office-hours/2022-10-05-enum-select-options at main · redwoodjs/redwood-office-hours · GitHub](redwood-office-hours/2022-10-05-enum-select-options at main · redwoodjs/redwood-office-hours · GitHub} The Problem Cannot get values from the enum to make a select control because Redwood generates the enum as a type -- and that m...
🌐
Reddit
reddit.com › r/node › how to do this in prisma (orm)?
r/node on Reddit: How to do this in Prisma (ORM)?
December 21, 2022 -

Has anyone worked with Prisma? How could I tell a model that if it doesn't write the Role field, i by default will be "Customer"?

I get an alert if I do it like this:

: Error validating: This line is not a valid field or attribute definition.

In another ORM like Sequalize it's something like this:

  role: {
    allowNull: false,
    type: DataTypes.STRING,
    defaultValue: 'customer'
  }

This is all the model in Sequalize

const UserSchema = {
  id: {
    allowNull: false,
    autoIncrement: true,
    primaryKey: true,
    type: DataTypes.INTEGER
  },
  email: {
    allowNull: false,
    type: DataTypes.STRING,
    unique: true,
  },
  password: {
    allowNull: false,
    type: DataTypes.STRING
  },
  role: {
    allowNull: false,
    type: DataTypes.STRING,
    defaultValue: 'customer'
  },
  createdAt: {
    allowNull: false,
    type: DataTypes.DATE,
    field: 'create_at',
    defaultValue: Sequelize.NOW
  }
}

🌐
Instagit
instagit.com › prisma › prisma › how-do-i-get-prisma-enum-in-client
How to Get Enums in Prisma Client: Accessing Generated Prisma Enum Types | prisma | Instagit
The Prisma namespace contains all generated types and enums for server-side TypeScript usage. The $Enums namespace is a browser-specific export that provides only the enum objects to support client-side bundling and tree-shaking.
🌐
Snyk
snyk.io › snyk vulnerability database › npm
prisma-enum-generator vulnerabilities | Snyk
January 3, 2023 - Automatically generate enums with your Prisma model names.
🌐
Answer Overflow
answeroverflow.com › m › 1226365489211642069
How to use enum? - Prisma
April 7, 2024 - // schema.prisma model Job { id Int @id @default(autoincrement()) name String company String status Status @default(APPLIED) } enum Status { OFFERED REJECTED APPLIED PENDING } Does anyone know how to resolve this error?