admin管理员组文章数量:1435859
Lets say I have this Prisma Schema :
model User {
id String @id @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String @unique
username String
}
Is there a way I can get lets say email's type in my app ?
- One options I can e with is a file that will export types but that way everytime I make a change to my prisma schema I will have to go there and manually edit the type.
Lets say I have this Prisma Schema :
model User {
id String @id @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String @unique
username String
}
Is there a way I can get lets say email's type in my app ?
- One options I can e with is a file that will export types but that way everytime I make a change to my prisma schema I will have to go there and manually edit the type.
1 Answer
Reset to default 7Prisma by default generates types for all your models. You could import it like this:
import { PrismaClient, User } from '@prisma/client';
Your models will always be in sync with your schema file, anytime you change the schema file, you could execute npx prisma generate
to update the PrismaClient and the generated types for your models.
本文标签: javascriptHow can I export my model39s properties types from Prisma SchemaStack Overflow
版权声明:本文标题:javascript - How can I export my model's properties types from Prisma Schema? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745669083a2669460.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论