P
Prisma7mo ago
/luna

Cleaner Way to Write Prisma Schema for Badge System

I'm working on a badge system for my web app and would appreciate any suggestions for cleaning up this Prisma schema datasource db { provider = "mongodb" url = env("DATABASE_URL") } model User { //alot of code nobody should see badges UserBadge[] } model Badge { id String @id @default(auto()) @map("_id") @db.ObjectId name String icon String users UserBadge[] } model UserBadge { id String @id @default(auto()) @map("_id") @db.ObjectId userId String badgeId String user User @relation(fields: [userId], references: [id]) badge Badge @relation(fields: [badgeId], references: [id]) @@unique([userId, badgeId]) }
4 Replies
Lord Zd
Lord Zd7mo ago
I would advise aliging your columns for readability but thats about it
Lord Zd
Lord Zd7mo ago
No description
/luna
/lunaOP7mo ago
would it be possible to remove the UserBadge model without errors?
Lord Zd
Lord Zd7mo ago
If you remove all references to UserBadge and there's no data in the table

Did you find this page helpful?