I want to create a simple table:
Users
---
id
name
friends
friends
field should be an array of other user ids. I'm trying to define a schema for this in schema.prisma
:
model User {
id String @id @default(uuid())
name String
friends User[]
}
Saving the file autocompletes the schema to this:
model User {
id String @id @default(uuid())
name String
friends User[] @relation("UserToUser")
User User? @relation("UserToUser", fields: [userId], references: [id])
userId String?
}
I'm not sure how to interpret this. I have read the Prisma docs about one-to-many self relations, but since it states
This relation expresses the following:
- "a user has zero or one teachers"
- "a user can have zero or more students"
I doubt it's what I want. How do I get the "a user can have zero or more students" without the "a user has zero or one teachers" part?