Closed
Description
Schema
model User {
id Int @id @default(autoincrement())
username String @unique
employedBy CompanyUser[]
properties PropertyUser[]
companies Company[]
@@allow('all', true)
}
model Company {
id Int @id @default(autoincrement())
name String
companyUsers CompanyUser[]
propertyUsers User[]
properties Property[]
@@allow('all', true)
}
model CompanyUser {
company Company @relation(fields: [companyId], references: [id])
companyId Int
user User @relation(fields: [userId], references: [id])
userId Int
dummyField String
@@id([companyId, userId])
@@allow('all', true)
}
enum PropertyUserRoleType {
Owner
Administrator
}
model PropertyUserRole {
id Int @id @default(autoincrement())
type PropertyUserRoleType
user PropertyUser @relation(fields: [userId], references: [id])
userId Int
@@allow('all', true)
}
model PropertyUser {
id Int @id @default(autoincrement())
dummyField String
property Property @relation(fields: [propertyId], references: [id])
propertyId Int
user User @relation(fields: [userId], references: [id])
userId Int
roles PropertyUserRole[]
@@unique([propertyId, userId])
@@allow('all', true)
}
model Property {
id Int @id @default(autoincrement())
name String
users PropertyUser[]
company Company @relation(fields: [companyId], references: [id])
companyId Int
@@allow('all', true)
}
Code
await db.user.create({
data: {
username: 'test@example.com',
},
});
await db.company.create({
data: {
name: 'My Company',
companyUsers: {
create: {
dummyField: '',
user: {
connect: {
id: 1,
},
},
},
},
propertyUsers: {
connect: {
id: 1,
},
},
properties: {
create: [
{
name: 'Test',
},
],
},
},
});
await db.property.update({
data: {
users: {
create: {
dummyField: '',
roles: {
createMany: {
data: {
type: 'Owner',
},
},
},
user: {
connect: {
id: 1,
},
},
},
},
},
where: {
id: 1,
},
});
Error
"Error calling enhanced Prisma method `update`: ",
"Invalid `db[model].create()` invocation in",
"node_modules\\@zenstackhq\\runtime\\enhancements\\policy\\handler.js:328:44",
"",
" 325 if (this.shouldLogQuery) {",
" 326 this.logger.info(`[policy] \\`create\\` ${model}: ${(0, utils_1.formatObject)(createArgs)}`);",
" 327 }",
"→ 328 const result = yield db[model].create({",
" data: {",
" dummyField: \"\",",
" user: {",
" connect: {",
" id: 1",
" }",
" },",
" roles: {",
" createMany: {",
" data: [",
" {",
" type: \"Owner\"",
" }",
" ]",
" }",
" },",
" propertyId: 1,",
" + property: {",
" + create: PropertyCreateWithoutUsersInput | PropertyUncheckedCreateWithoutUsersInput,",
" + connectOrCreate: PropertyCreateOrConnectWithoutUsersInput,",
" + connect: PropertyWhereUniqueInput",
" + }",
" },",
" select: {",
" id: true,",
" roles: {",
" select: {",
" id: true",
" }",
" }",
" }",
" })",
"",
"Argument `property` is missing.",
" at Object.updateOneProperty