-
-
Notifications
You must be signed in to change notification settings - Fork 126
Closed
Labels
Description
ZModel:
model Tenant {
id String @id @default(uuid())
users User[]
content Content[]
}
model User {
id String @id @default(uuid())
tenantId String @default(auth().tenantId)
tenant Tenant @relation(fields: [tenantId], references: [id])
posts Post[]
likes PostUserLikes[]
@@allow('all', true)
}
model Content {
tenantId String @default(auth().tenantId)
tenant Tenant @relation(fields: [tenantId], references: [id])
id String @id @default(uuid())
contentType String
@@delegate(contentType)
@@allow('all', true)
}
model Post extends Content {
author User @relation(fields: [authorId], references: [id])
authorId String @default(auth().id)
comments Comment[]
likes PostUserLikes[]
@@allow('all', true)
}
model PostUserLikes extends Content {
userId String
user User @relation(fields: [userId], references: [id])
postId String
post Post @relation(fields: [postId], references: [id])
@@unique([userId, postId])
@@allow('all', true)
}
model Comment extends Content {
postId String
post Post @relation(fields: [postId], references: [id])
@@allow('all', true)
}TS:
const tenant = await prisma.tenant.create({ data: {} });
const user = await prisma.user.create({ data: { tenantId: tenant.id } });
const db = enhance({ id: user.id, tenantId: tenant.id });
await db.post.create({
data: {
likes: {
createMany: {
data: [
{
userId: user.id,
},
],
},
},
},
include: {
likes: true,
},
});Error:
const result = await db[model].create({
data: {
likes: {
create: [
{
delegate_aux_content: {
create: {
contentType: "PostUserLikes"
}
},
user: {
connect: {
id: "a6b6af76-0320-4761-ba41-e78b8a05ccf9"
}
}
}
]
},
author: {
connect: {
id: "a6b6af76-0320-4761-ba41-e78b8a05ccf9"
}
},
delegate_aux_content: {
create: {
contentType: "Post",
tenant: {
connect: {
id: "0bb02fe8-c823-4a3a-8843-2068c6072971"
}
}
}
}
},
select: {
id: true,
likes: {
select: {
id: true
}
}
}
})
Argument `tenant` is missing.
ZenStack version: 2.12.0