Prisma - creating row with empty array fields
Hi, I have a user table in which I have a reference field of the Story table, written like this:
story Story[]
When I create a new user, since this field cannot be optional in prisma, I write it like this:
return await prisma.story.create({
data: {
...
story: [],
},
});
I get this error: got invalid value [] on prisma.createOneStory. Provided List<>6 Replies
if its setup to something akin to
categories Category[] @relation(references: [id])
in your schema is that still true?
i cant imagine related fields have to be created
Right now my user table has:
story Story[]
and my story table has:
user User @relation(fields: [userId], references: [id])
userId String
as far as im aware even if the field cant be set to optional you can still create a user without posts, just dont do posts: [] when creating the user
Yea not passing story should work but I'm not sure
Ct3a does this with session I believe from a schema perspective
you should not pass story: [] while you are creating it
Ok thanks I will try without