Stefano Giraldi
12/07/2021, 9:02 AMUser
and Role
schemas.
In my seed.ts
I have this code
const superadminRole = await prisma.role.upsert({
where: { name: 'superadmin' },
update: {},
create: {
name: 'superadmin',
},
})
const superadmin = await prisma.user.upsert({
where: { email: '<mailto:superadmin@test.com|superadmin@test.com>' },
update: {},
create: {
email: '<mailto:superadmin@test.com|superadmin@test.com>',
name: 'Super Admin',
password: hash,
roles: {
connect: [{name: superadminRole.name}] <--- ts2322 error
}
},
})
I get this typescript error (even if the script works right).
Type '{ name: string; }' is not assignable to type 'UserRoleWhereUniqueInput'.
Object literal may only specify known properties, and 'name' does not exist in type 'UserRoleWhereUniqueInput'.ts(2322)
Can someone help me to understand what is the problem? Thank younikolasburk
Stefano Giraldi
12/07/2021, 9:29 AMmodel User {
id String @id @default(uuid()) @db.Uuid
email String @unique @db.VarChar(255)
name String? @db.VarChar(255)
password String @db.VarChar(255)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
roles Role[]
RefreshToken RefreshToken[]
Post Post[]
}
model Role {
id Int @id @default(autoincrement())
name String @unique @db.VarChar(255)
users User[]
}
Stefano Giraldi
12/07/2021, 11:23 AMsuperadminRole.name
variable and file node_modules/.prisma/client/index.d.ts
was opened in my editor and the variable type was resolved.Stefano Giraldi
12/07/2021, 11:25 AMindex.d.ts
file path right? (inside node_modules
)nikolasburk
It seems was a problem with my vscode. I’ve check the Type definition (Go to Type definition in the contextual menu) overGlad to hear 🙌variable and filesuperadminRole.name
was opened in my editor and the variable type was resolved.node_modules/.prisma/client/index.d.ts
isCan you elaborate on this? Prisma Client is generated intofile path right? (insideindex.d.ts
)node_modules
node_modules
by default so I don’t see an issue here. If you want to generate it somewhere else, you can add the `output` field to the `generator` block.Stefano Giraldi
12/07/2021, 11:31 AM