Prisma trpc schema multiple models
Hi guys I built a basic t3 stack app, and right now I am stuck. I am trying to create an additional model while creating another one.
This is how my schema looks like:
And this is how I try to create the model
17 Replies
While create a movie I am also trying to create an answer for that movie and connect them by relation.
But right now here
I get this error:
This:
Also returns:
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yes
While creating a movie in my movie's route mutation I try to create an answer and immidiatly connect their relation
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Hmm but that would not resolve my second mutation since I need the created answer.id right?
So you mean something like this right?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yes
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yeah but
ctx.prisma.answer.create
does not return a promise right, not sure if I am missing something 🤔Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Here
answer has this return type:
const answer: Prisma.Prisma__AnswerClient<Answer, never>
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ok that works for the answer.id issue :D, I thought that it should work since default it is not async.
Looks like this now
But the code below
// Connect the new Movie to the existing Answer using the 'movies' relation field
has still a warning
Any idea how to resolve that?
ohwait
nevermind fixed that one
works now I think thanks 😄Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yeah what confused me is that
.create
did not return a promise default, so I just thought not to use it as a promise
But now I know thanks 🙂Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ty