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:
You can just import the model type from prisma like
import { Product } from '@prisma/client'
import { Product } from '@prisma/client'
where you have a prisma model named "Product"
O
oadster377d ago
Why don't you just use the type from prisma?
Solution
O
oadster377d ago
You can just import the model type from prisma like
import { Product } from '@prisma/client'
import { Product } from '@prisma/client'
where you have a prisma model named "Product"
M
.majamin377d ago
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.
Want results from more Discord servers?
Add your server
More Posts