4jandals
WWasp
•Created by 4jandals on 5/2/2025 in #đŸ™‹questions
Best way to generate null form values for a Prisma update
Not sure best place to ask this question, but I figure developers building CRUD forms in wasp might have the same question.
I have an entity like this:
I'm updating the entity like this in the back-end:
I have a Zod schema in the front-end code
In my form if I clear the value of
bar
it generates the following for updatedData
:
As a result bar
will be ignored in the Prisma update and so it doesn't clear to null.
What's best practise here?:
1. Do I need to find a way to get Zod to generate null for empty fields (I've tried)
2. Or do I need to convert fields that are undefined to null in the updatedData
object before using Prisma to update the object.
I've read this https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/null-and-undefined which indicates that undefined should be avoided in Primsa.10 replies
WWasp
•Created by 4jandals on 4/4/2025 in #đŸ™‹questions
Is there a recommended way to add computed fields to a model?
For example, let's say I have a Person entity with a dateOfBirth, and I want to derive age in the model so I can reuse that across the UI.
I think Prisma client supports compute, but not sure how to use that in Wasp? Or maybe there is a better way?
6 replies