I've been using this ORM for months now but I still feel like I'm doing it a hacky way. Usually I just make a separate type clone of the prisma schema file but i feel like that's a violation of DRY.
Can I use the Prisma.X types like this somehow, especially when there are include being used? I can't find any in the definitions file for how you'd get the included relations in the type.
Like this: const data = req.body as WebDataRequestBody<BankAccount>; won't include owners, but if i use Prisma.BankAccountUpdateInput then it will cast owners to something completely different with functions, making the insertion impossible.
Thanks.
#What to cast the incoming data as in typescript?
5 messages · Page 1 of 1 (latest)
Hey @amber lichen 👋
Have you seen this section of docs?
This aims to solve the exact same issue that you are talking about
https://www.prisma.io/docs/concepts/components/prisma-client/advanced-type-safety/operating-against-partial-structures-of-model-types#problem-using-variations-of-the-generated-model-type
That seems to be it, thanks. Found the docs to be extremely confusing with its titling.
Thanks for the feedback.
I assume it was difficult to find this section of docs because of it's title?
Whoops, no notification. Yes, I usually don't read docs from start to finish but the parts I need, so in my case it was really hidden. I think I searched for "combined" and some other terms but it seems they did not apply.