I'm learning Prisma,
I want to leverage Prisma's Implicit relations as much as possible for the following relation (and later I want to use nexus for writing queries):
1 User can belong to Many Conversations (as it's participant)
1 Conversation has an array os users (called participants)
1 User can own Many Messages (as it's author)
1 Message can have 1 User (as it's author)
1 Conversation has an array of messages (called texts)
1 Message can only belong to 1 Conversation
So far I have come up with this (but I highly doubt it's correct because its not behaving as I want it to when using with nexus):
model User {
id String @id @default(uuid())
conversations Conversation[]
}
model Message {
id String @id @default(uuid())
authorId String
conversationId String
author User @relation(fields: [authorId], references: [id])
conversation Conversation @relation(fields: [conversationId], references: [id])
}
model Conversation {
id String @id @default(uuid())
participants User[]
messages Message[]
}
Could I please get some pointers/help to proceed?