Insert Schemas with onConflictDoUpdate
I'm trying to leverage the
onConflictDoUpdate
method to update a record if it already exists. The problem is that I create an insert schema with drizzle-zod
that enforces the non nullable fields are set. In the case where the record already exists, it is valid to pass in partial data to my function, but that then fails the insert schema validation.
Is there any way to parse the insert schema only if there is no conflict?
My current workaround is to separate the insert and update logic.1 Reply
I believe this message might guide you in the right direction: https://discord.com/channels/1043890932593987624/1159477232608223293/1159849737248313395