Problem
I have a requirement on the project to be able to prefix all keys (all my Id fields are cuid() generated).
Suggested solution
Ideally:
model Customer {
id String @default(cuid(prefix: "cust_")) @id
email String @unique
name String?
}
model Product {
id String @default(cuid(prefix: "sku_")) @id
title String?
}
Alternatives
Alternately, since cuid() is not executed at DB level, I could handle it in the app too. However, it will be good to see it enhanced in prisma itself.
Additional context
- It would be good if there was a way to extend good for developers. Above is one use-case.
- Lets say you have a Pages or Account table and you want
@id to be a perma slug. Such table will ever have few hundred records and you'd want something Url friendly but not as long as cuid.
https://github.com/ericelliott/cuid#short-urls
Problem
I have a requirement on the project to be able to prefix all keys (all my Id fields are
cuid()generated).Suggested solution
Ideally:
Alternatives
Alternately, since
cuid()is not executed at DB level, I could handle it in the app too. However, it will be good to see it enhanced in prisma itself.Additional context
@idto be a perma slug. Such table will ever have few hundred records and you'd want something Url friendly but not as long ascuid.https://github.com/ericelliott/cuid#short-urls