简体   繁体   中英

How to get specific unique string value in Prisma

in my Prisma model how can I define data type string with a specific format like character with auto-generated number something like this C00000001 .

Here is my model:

model Company {
  id                 String      @unique // Here it should insert C00000001, C00000002 and so on
  companyName        String      @unique
  companyDescription String
  createdAt          DateTime    @default(now())
  updatedAt          DateTime    @updatedAt
}

At the moment, this feature is not supported in Prisma. There is a feature request to support custom-defined id patterns as seen here . Some workarounds that utilize the use of middleware are also discussed there.

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