Adam
10/19/2021, 8:48 PMprisma.role.create({
data: {
Id: 1,
Name: 'Test',
Description: 'Test',
IsActive: true,
CreatedByUser: { connect: { Id: 2 } },
LastUpdateByUser: { connect: { Id: 2 } },
},
});
and PrismaClient doesn’t allow me to, because of:
Types of property 'Id' are incompatible. Type 'number' is not assignable to type 'never'.`
and hinting me about:
The expected type comes from property 'data' which is declared here on type '{ select?: RoleSelect; include?: RoleInclude; data: (Without<RoleCreateInput, RoleUncheckedCreateInput> & RoleUncheckedCreateInput) | (Without<...> & RoleCreateInput); }'
and my question is - why PrismaClient doesn’t allow me to use Id for creating?
in my model schema I have simply:
Id Int @id @default(autoincrement())
Similar result I have with upsert as well. And what is totally weird to me - some models works fine. I already spend 2 hours to figure out why it happens to this particular model. Can anyone help?Austin
10/19/2021, 10:00 PMschema.prisma
file?Adam
10/20/2021, 7:12 AMprisma/seed.ts
file and run prisma db seed
with:
"prisma": {
"seed": "ts-node prisma/seed.ts"
}
in package.json.
My schema.prisma has around 1.5k lines and I can’t share it all, but I hope it would be anyhow helpful.
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model Role {
Id Int @id @default(autoincrement())
Name String @db.VarChar(300)
Description String? @db.VarChar(2000)
IsActive Boolean
DefaultForProjectRole Int?
CreatedByUserId Int
CreatedDateTime DateTime @default(now())
LastUpdateByUserId Int
LastUpdateDateTime DateTime @updatedAt
DefaultForProjectRoleRelation ProjectRole? @relation(fields: [DefaultForProjectRole], references: [Id])
CreatedByUser TaskerUser @relation(fields: [CreatedByUserId], references: [Id], name: "RoleCreatedByUser")
LastUpdateByUser TaskerUser @relation(fields: [LastUpdateByUserId], references: [Id], name: "RoleLastUpdateByUser")
TaskerUserRole TaskerUserRole[]
PermissionToRole PermissionToRole[] @relation("PermisionToRoleRole")
ProjectRoleToProjectToRole ProjectRoleToProjectToRole[]
@@map(name: "role")
}
I use 3.2.1
version of prisma
and @prisma/client
.Austin
10/20/2021, 6:57 PM