Skip to content

Commit

Permalink
feat(be): create prisma follow model
Browse files Browse the repository at this point in the history
  • Loading branch information
acatzk committed Jan 30, 2024
1 parent 7a36a9b commit 42f6b62
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/layouts/profile-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ProfileLayout({ children }: ProfileLayoutProps): JSX.Ele
const username = extractUsernameFromPath(pathname)

const user = trpc.user.getUserByUsername.useQuery({
username: username!
username
})

const handleGoBackRoute = (): void => {
Expand Down
17 changes: 15 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,21 @@ model User {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
role Role @default(USER)
posts Post[]
role Role @default(USER)
posts Post[]
followers Follow[] @relation("FollowerRelation")
following Follow[] @relation("FollowingRelation")
}

model Follow {
id Int @id @default(autoincrement())
follower User @relation("FollowerRelation", fields: [followerId], references: [id], onDelete: Cascade, onUpdate: Cascade)
followerId Int
following User @relation("FollowingRelation", fields: [followingId], references: [id], onDelete: Cascade, onUpdate: Cascade)
followingId Int
createdAt DateTime @default(now())
@@unique([followerId, followingId])
}

enum Role {
Expand Down

0 comments on commit 42f6b62

Please sign in to comment.