Annie Tsai
05/16/2022, 7:23 PMupsert method with a multi-column unique constraint, e.g.:
// schema.prisma
model X {
id ...
...
email String
subdomain String
@@unique([email, subdomain])
}
// api
const upsertX = async params => {
const { email, subdomain } = params;
const upsertedX = await prisma.x.upsert({
where: { email_subdomain: { email, subdomain } },
update: { ... },
create: { email, subdomain, ... },
});
};
for some reason, the upsert call always runs for a long time and times out. I tried using prisma.x.findMany({ where: { email, subdomain } }) instead and that seems to work fine… but shouldn’t the unique constraint make querying by email_subdomain faster (or at the very least, it shouldn’t time out). am I missing something?Ruben Amendoeira
05/16/2022, 7:27 PMAnnie Tsai
05/16/2022, 8:19 PMAnnie Tsai
05/16/2022, 8:22 PMawait prisma.x.upsert({
where: { email, subdomain },
...
)};
I get an error that email does not exist on XWhereUniqueInputRuben Amendoeira
05/16/2022, 8:29 PMAnnie Tsai
05/16/2022, 9:20 PMNurul
05/25/2022, 12:23 PM@prisma/client version?