Awey
11/13/2021, 8:35 AMmodel User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
email String @unique
username String @db.VarChar(50)
password String
...
}
model Message {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
subject String
body String
}
I'm having trouble understanding how to best setup the relationships for a 1 on 1 private messaging system.
I'd like for it to work similar to how Reddit handles private messages. Could someone point me in the right direction please.Awey
11/16/2021, 7:44 AMAwey
11/16/2021, 7:51 AMRyan
11/16/2021, 12:29 PMRyan
11/16/2021, 12:34 PMmodel User {
id Int @id @default(autoincrement())
name String
rooms Room[]
messages Message[]
}
model Room {
id Int @id @default(autoincrement())
messages Message[]
users User[]
}
model Message {
id Int @id @default(autoincrement())
content String
user User @relation(fields: [userId], references: [id])
Room Room? @relation(fields: [roomId], references: [id])
userId Int
roomId Int?
}
This is something that you could use as a starter.Awey
11/18/2021, 9:09 AMRyan
11/18/2021, 11:34 AM