/luna
/luna
PPrisma
Created by /luna on 7/13/2024 in #help-and-questions
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]) }
6 replies