Reputation: 291
This is the user model of my current prisma.scheme:
model User{
@@map("users")
ID Int @id @default(autoincrement()) @unique
Firstname String @map("firstname") @db.VarChar(45)
Lastname String @map("lastname") @db.VarChar(45)
Phone String @map("phone") @db.VarChar(60) @unique
EMail String @map("email") @db.VarChar(45) @unique
Username String @map("username") @db.VarChar(45) @unique
Password String @map("password") @db.VarChar(255)
Role Role @map("role") @relation(fields:[Role],references:[ID])
IsLocked Boolean @map("isLocked") @default(false)
Avatar String? @db.VarChar(36) @unique
}
For the "Role" column I get the following error:
Error parsing attribute "@map": The attribute `@map` cannot be used on relation fields.
Is there a way I can map these columns as well?
Upvotes: 0
Views: 1493
Reputation: 1675
@map
and @@map
allow you to name columns and tables differently than what Prisma's default naming convention derives from your field and model names.
You can't use @map
for relation fields because they do not end up as columns in your database. Providing a custom name with @map
would not make any sense. You can easily confirm this by having a look into your database with Prisma Studio for example.
Upvotes: 1