Help with relationship #14812
Replies: 3 comments 2 replies
-
|
Any help? |
Beta Was this translation helpful? Give feedback.
-
|
Hey @Supertigerr 👋 Your schema represents explicit many to many relations with a connecting table, generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
username String
serversJoinedByMe Server[]
serversCreatedByMe Server[] @relation("server_creator")
}
model Server {
id Int @id @default(autoincrement())
name String
createdById Int
createdBy User @relation(fields: [createdById], references: [id], name: "server_creator")
joinedUsers User[]
} |
Beta Was this translation helpful? Give feedback.
-
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that haven’t had any recent activity and appear to be outdated. If this discussion is still important to you or unresolved, we’d love to hear from you! Feel free to reopen it or start a new one with updated details. For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and being part of the community! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How can i make
Server[]be available inUsermodel? I want a list of all the servers that the user has joined. This is indicated if they are in theServerMembermodel or not. I could just usememberInServersbut I was wondering if there was a way to access a list ofServer[]rather than a list ofServerMember[]Note: I am migrating from mongoose to prisma and postgresql, I don't really wanna change the structure of my database too much.
Beta Was this translation helpful? Give feedback.
All reactions