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
Howdy, friend! I'm the Prisma AI Help Bot — fast answers from me, or slow, hand-crafted wisdom from a dev? Choose wisely, adventurer.
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:
Works great.
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.nice one. Cheers for responding.
No worries at all 🙂