Is there actually a best practice when it comes to naming conventions?

Yes, I've read the docs but found the weren't particularly explicit in what best practice actually is. What I've been able to deduce is the following: 1. It's best practice to use PascalCase for Prisma model names 2. It's best practice to use camelCase for Prisma column names 3. It's best practice to use snake_case for everything in Postgres 4. You can map tables and columns using @@map and @map respectively 5. Prisma will never automatically manipulate case So, if the above points are correct should I therefore conclude that it's best practice to @map every table and @@map every column just to handle the case translation?
5 Replies
Prisma AI Help
Prisma AI Help5mo ago
Howdy, friend! I'm the Prisma AI Help Bot — fast answers from me, or slow, hand-crafted wisdom from a dev? Choose wisely, adventurer.
RapidScampi
RapidScampiOP5mo ago
after hunting around a bit I was able to find the prisma-case-format npm package that makes it really easy to keep map fields consistent. Example command:
npx prisma-case-format --file ./prisma/schema.prisma --table-case pascal --field-case pascal --map-table-case snake --map-field-case snake --map-enum-case snake --pluralize
npx prisma-case-format --file ./prisma/schema.prisma --table-case pascal --field-case pascal --map-table-case snake --map-field-case snake --map-enum-case snake --pluralize
Works great.
Nurul
Nurul5mo ago
I am glad to hear that prisma-case-format worked out for you 🙌 Your summary of best practices is correct. You can use @map and @@map for every field and model where you want to map between Prisma's naming conventions and your database's naming conventions. There is no built-in automatic case translation in Prisma at this time.
RapidScampi
RapidScampiOP5mo ago
nice one. Cheers for responding.
Nurul
Nurul5mo ago
No worries at all 🙂

Did you find this page helpful?