edarcode
edarcode
Explore posts from servers
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
mmm ok ok
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
My idea is to consult the user directly and from there select some data from their relationships, so as not to have to make 2 queries.
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
but _count works correctly for you?
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
I saw you writing bro xD @Nurul (Prisma)
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
@Nurul (Prisma)
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
No description
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
model User {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

followers Follow[] @relation("followers")
following Follow[] @relation("following")
}

model Follow {
followerId String
followingId String
createdAt DateTime @default(now())

follower User @relation("followers", fields: [followerId], references: [id])
following User @relation("following", fields: [followingId], references: [id])

@@id([followerId, followingId])
}
model User {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

followers Follow[] @relation("followers")
following Follow[] @relation("following")
}

model Follow {
followerId String
followingId String
createdAt DateTime @default(now())

follower User @relation("followers", fields: [followerId], references: [id])
following User @relation("following", fields: [followingId], references: [id])

@@id([followerId, followingId])
}
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
yes 1s
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
I really don't want to leave Prisma, I like it a lot. And I don't see any alternatives either. So I don't know what to do.
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
I have deleted package.lock, updated dependencies, asked many colleagues, etc. and I have not been able to find the error, I have checked my schema a thousand times, I am dead, I have asked chatGPT. I have read the doc
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
No description
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
No description
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
So when I check A and his followers it should return a 0, and his following should return a 1, but it comes out the other way around. And I'm very frustrated because I've already checked every possible error in detail and I don't see anything wrong T.T @Nurul (Prisma)
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
As you can see, A or followerId already follows B or followingId
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
No description
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
To represent this follow-up, there must be a table containing AId and BId, I named it Follow
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
Currently there are 2 users, the idea is that user A follows user B
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
No description
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
No description
30 replies
PPrisma
Created by edarcode on 8/13/2024 in #help-and-questions
self-relation
No description
30 replies