Matching types to Prisma models
I have a T3 boilerplate with Prisma and PlanetScale as per Theo's T3 Stack Tutorial. I'm trying to create a dynamic route for a product under /shop that will accept a router query of the product ID. What is the best practice in this environment to create a type for a product, but using the already-existing model in the prisma schema? I could just create my own type, of course, but then that seems like it's a duplication of effort (creating the prisma model AND the type, and having to update both). Any advice would be great. Thank you
Solution:Jump to solution
You can just import the model type from prisma like where you have a prisma model named "Product"
3 Replies
Why don't you just use the type from prisma?
Solution
You can just import the model type from prisma like where you have a prisma model named "Product"
Thanks, that's exactly it. This is my first time using Prisma, and I'm glad there's a way to do this so easily.