Need help with setting up prisma schemas

so basically I want a user to be able to create and join events. I've set up a way to identify the host of an event, but not how to keep track of the members of the event (those who join the event). I kept getting some errors when I tried to implement it myself and it was hard to keep track of them so i got rid of what i had cause it was not working. What is a good way of keeping track of Users who join the event?
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
hostedEvents Event[] @relation(name: "hostEvent")
}

model Event {
id String @id @default(cuid())
name String
description String
startDate DateTime
endDate DateTime
location String
link String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
hostId String
host User @relation("hostEvent", fields: [hostId], references: [id])
Gallery Gallery[]
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
hostedEvents Event[] @relation(name: "hostEvent")
}

model Event {
id String @id @default(cuid())
name String
description String
startDate DateTime
endDate DateTime
location String
link String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
hostId String
host User @relation("hostEvent", fields: [hostId], references: [id])
Gallery Gallery[]
}
5 Replies
Alex
Alex3y ago
What about adding a property „member“ which is User[] to the Event?
packofm&ms
packofm&msOP3y ago
I tried that, and but I couldnt figure out how to set up the @relation parameters if anyone knows how to do this pls @ me
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
packofm&ms
packofm&msOP3y ago
i don't entirely understand that last part
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server