#Prisma - How do you guys prefer to setup your Models?
5 messages · Page 1 of 1 (latest)
I tend to think module-wise when creating my schema. While your code doesn't necessarily have to have a working module enabling/disabling, you can have separate models for each module/category.
This means that on a Guild, there can be a LoggingModule which stores info about logging, a ModerationModule which stores info about moderation.
The models would be 1-1 relation of course.
Although if your bot only specialises in logging for example, this wouldn't be too useful
Sorry for the late response, have been busy. But I agree! Did some researching on my own and found working with modules seemed better to me 😄
I did however have a question about Users, since multiple guilds can have multiple users, and possibly some of the same members, wouldn't it be best to store users containing something like "guild profiles" and storing those guild profiles in the Guild ?
ex:
model Guild {
guildId String @id @unique
guildName String
guildBrandName String @default("")
users UserProfile[]
}
model User {
userId String @id @unique
guildProfiles UserProfile[]
}
model UserProfile {
user User @relation(fields: [userId], references: [userId])
guild Guild @relation(fields: [guildId], references: [guildId])
userId String @id
guildId String
@@unique([userId, guildId])
}
I would say unless it's necessary to fetch a user's guilds you don't need it