Closed nicholaschiang closed 2 years ago
In app/routes/index.ts
, I tried doing something like:
await db.influencers.upsert({
create: {
...influencer,
tokens: {
connectOrCreate: {
create: token,
where: { influencer_id: token.influencer_id },
},
},
},
update: influencer,
where: { id: influencer.id },
});
But that won't upsert the token row if it already exists, which is what needs to happen. Currently, Prisma doesn't support a nested upsert within an upsert (you can only nest upserts within an update I think): https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#upsert-1
Prisma also doesn't seem to support many-to-many nested relation creation.
Imported from @nicholaschiang's original Linear issue TS-87.