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
needmorewood
needmorewood2y ago
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
Aviv
AvivOP2y ago
Right now my user table has: story Story[] and my story table has: user User @relation(fields: [userId], references: [id]) userId String
splitfire?
splitfire?2y ago
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
needmorewood
needmorewood2y ago
Yea not passing story should work but I'm not sure Ct3a does this with session I believe from a schema perspective
Abuzeid
Abuzeid2y ago
you should not pass story: [] while you are creating it
Aviv
AvivOP2y ago
Ok thanks I will try without
Want results from more Discord servers?
Add your server