Hi, I have following prisma model and auto generated Zod object
I am trying to use it when adding a new Article. But generated DTO has id property as optional. Prisma client expects id to never exist. How should I handle this?
I am able to use Omit to handle just the issue of id property but then it creates another issues, for example that title is optional in my DTO but it's required by prisma model.
I am looking for optimal way of handling this, so that I don't have to create multiple classes, types or interfaces.
Edit: I see that type inferred from Zod, gives my optional title property, while it should be required. Is there a way around this?
Hi, I have following prisma model and auto generated Zod object
I am trying to use it when adding a new Article. But generated DTO has
id
property as optional. Prisma client expects id to never exist. How should I handle this?I am able to use
Omit
to handle just the issue ofid
property but then it creates another issues, for example that title is optional in my DTO but it's required by prisma model.I am looking for optimal way of handling this, so that I don't have to create multiple classes, types or interfaces.
Edit: I see that type inferred from Zod, gives my optional
title
property, while it should be required. Is there a way around this?