Hello all
I have a schema as
model Business {
id String @id @default(uuid())
name String
}
model Role {
id String @id @default(uuid())
name String
business Business? @relation(fields: [business_id], references: [id])
business_id String?
@@unique([business_id, name])
@@map("role")
}
I have a scenario to add roles with business OR without business.
How this can be achieved with upsert.
I have tried to run below query, but it returns error. error screenshot attached as well
await prisma.role.upsert({
where: { business_id_name: { business_id: null, name: 'Owner' } },
update: {},
create: {
business_id: null,
name: 'Owner',
},
});