Been stuck on this annoying problem with index and foreign key problems.
Lets say you have 2 models
model Follows {
id BigInt
followerId BigInt @map("follower_id")
followingId BigInt @map("following_id")
follower Users @relation("following", fields: [followerId], references: [id])
following Users @relation("follower", fields: [followingId], references: [id])
posts Posts @relation(fields: [followingId], references: [authorId], map: "follows_following_posts_fkey")
}
Now the Posts model
model Posts {
id BigInt
authorId BigInt
author Users @relation(field: [authorId], references: [id])
follows Follows[]
}
When I ultimately query Follows, include the Following Users, i also want to be able to fetch the posts of those following users. So the relation that the followingId of any user references to the posts model authorId which ultimately should give me back all the posts the following user has made?