prisma / prisma/orm

Support adding prefix to an `@id` field

Open
#3,391 39 comments 172 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature topic: default topic: extend-client topic: schema
Dominant language
TypeScript
Stars
47.6k
Forks
2.5k
Avg merge
21h 59m
Merged PRs (30d)
95

Description

model User {
  id       String    @default(cuid()) @id
}

It works. But I want to generate an Id that is easier to refer like user_c2ajhsad8923jiesd, company_c3jkasdhjkhaskd

Something like this could be helpful, thanks :)

model User {
  id       String    @default("user_" + cuid()) @id
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or entry point is named. Start by reviewing the 39-comment discussion and the ORM's existing @id and cuid handling to clarify the supported expression semantics. Done means a schema can generate an @id with a configured prefix and the resulting value follows the requested format.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.