P
Prisma3mo ago
ranco

Help with Prisma schema

Im working on a NextJS project with Prisma and mangoDB I have an Activity model that has a relationship with Member when first creating an Activity it dosn't have members only and owner but i still want to set the default value to an empty array. when I try to do so with a post request and set members: [] to an empty array i get this error: Argument members: Invalid value provided. Expected MemberCreateNestedManyWithoutActivityInput. will appreciate any help to solve this problem.
No description
No description
4 Replies
DevPanda
DevPanda3mo ago
show us the code snipped from create @ranco
HAO
HAO2mo ago
At first, Ensure the relation field in Prisma schema is set up correctly
DevPanda
DevPanda2mo ago
The problem is that it wants to describe a field when it is created, but this is automatically generated by the relation. Just leave out members in the create function and you're done @ranco
Dkyc
Dkyc2mo ago
use some code on the backend to add the members[] array to the data you pass to create function, if it has elements, otherwise leave it out completely as @DevPanda suggested or
delete data['members']
delete data['members']
in js, for the same thing if its empty
Want results from more Discord servers?
Add your server