Hello, I've defined an <implicit many-to-many rela...
# orm-help
s
Hello, I've defined an implicit many-to-many relation between
User
and
Role
schemas. In my
seed.ts
I have this code
Copy 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).
Copy code
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 you
n
Hey Stefano 👋 could you maybe also share your Prisma schema so we can try to properly reproduce the problem? 🙂
s
Sure!
Copy code
model 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[]
}
@nikolasburk It seems was a problem with my vscode. I've check the Type definition (Go to Type definition in the contextual menu) over
superadminRole.name
variable and file
node_modules/.prisma/client/index.d.ts
was opened in my editor and the variable type was resolved.
My question now is... is
index.d.ts
file path right? (inside
node_modules
)
n
It seems was a problem with my vscode. I’ve check the Type definition (Go to Type definition in the contextual menu) over 
superadminRole.name
 variable and file 
node_modules/.prisma/client/index.d.ts
 was opened in my editor and the variable type was resolved.
Glad to hear 🙌
is 
index.d.ts
 file path right? (inside 
node_modules
 )
Can you elaborate on this? Prisma Client is generated into
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.
👍 1
s
Awesome! Thank you @nikolasburk for your support 🙂
🙌 1
prisma rainbow 1