简体   繁体   中英

PRISMA: How to skip id field in prisma regular type?

Is there any way to skip id in when modeling a prisma type?

type User {
  myid: string! @unique
}

I have tried this. but is gives, ✖ One field of the type User must be marked as the id field with the @id directive.

actually I want to customize the prisma id. I dont want to use the default prisma id which always starts with ck---

I want different patterns of id for different types:

for example: user id: user---abc---123 product id: product---abc---123

the id in any field is supposed to identify it, customizing it won't give you any advantage if you want a uuid you can always use

model User {
      myid: String @default(uuid()) @id
}

or

model User {
      myid: Int @default(autoincrement()) @id
}

you can learn more here: https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/data-model

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM