#update with null values
28 messages · Page 1 of 1 (latest)
A code snippet would help too solve this problem as well. Such as what value you try to set it with
ok so the question would be, how to update an instance that has a relation inside with the relation id set to null? well check pic 1 that what's happens when i try to update it :S
update works great for instances with not relations
basically:
Hi @tawdry star, I have responded to the Github Discussion you opened. https://github.com/prisma/prisma/discussions/22331.
employeeId cannot be null. Prisma expects you to connect to an existing employeeId. A connect query connects a record to an existing related record. See the documentation
Thnaks for your time but yeah I already noticed it needs a value but I'm curious because I can do this in mongo where it just updates what has changes and prisma update isn't doing that
I guess there's no method equivalent¿?
here's the equivalent
await prisma.product.update({
where: { productId: input.product.productID },
data: { product: { set: input.product }
})
where will do the findOne part and data is what you provide to the model to update
I see so it has a set method??
yes of course
you need to set a property within the model not just the whole model
actually if your object contains the exact properties as the model, you should just be able to use ...input
i see, so i think my issue isn't even prisma, i'm generating zod schemas and i think the issue is the library i'm using
did a console log and the info isn't even reaching the endpoint
😂
Ooh very nice!