-
-
Notifications
You must be signed in to change notification settings - Fork 127
Closed
Milestone
Description
ZModel
model User {
id String @id @default(cuid())
companies CompanyUser[]
@@allow('all', true)
}
model Company {
id String @id @default(cuid())
users CompanyUser[]
@@allow('all', true)
}
model CompanyUser {
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
companyId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
@@id([companyId, userId])
@@allow('all', true)
}Code
const db = enhance(prisma);
await db.user.create({ data: { id: 'abc' } });
await db.user.create({ data: { id: 'def' } });
await db.company.create({ data: { id: '1', users: { create: { userId: 'abc' } } } });
await db.company.update({
where: { id: '1' },
data: {
users: {
createMany: {
data: [{ userId: 'abc' }, { userId: 'def' }],
skipDuplicates: true,
},
},
},
include: { users: true },
})The code should succeed but it results in unique constraint violation error.
Metadata
Metadata
Assignees
Labels
No labels