Hi there, I could use some help with two models th...
# prisma-client
p
Hi there, I could use some help with two models that have a many to many relationship (generated implicitly). If I have a existing records of the two models, and I try to connect one with the other, I am getting unkown arg errors for the model I am trying to connect.
Copy code
const events = await prisma.event.findMany()
await Promise.all(events.map(async e) => {
   const performers = await prisma.performer.findMany({ where: ..logicToFindPerformers });
   await prisma.event.update(
     { 
        where: { id: e.id }, 
        data: { performers: performers.map((p) => ({ id: p.id })) }
     }
   )
})
But I am getting this error message from the client:
Unknown arg 'performers' in data.performers for type EventUncheckedUpdateInput.
I can see from my generated schema that I do have a join table created (
_EventToPerformer
), so what is the correct way to join existing records in a many to many relationship?
r
@Paul T 👋 Answered here 🙂
p
Thanks!