'Follow/Unfollow Feature NestJS
I am trying to create a follow/unfollow system in my NestJS application. Currently I have a user table and joiner table follows. The follows table has the following structure
follows
| followerId | followingId |
|---|---|
| 1 | 2 |
| 1 | 3 |
| 3 | 2 |
- followerId the user creating the follow
- followingId the the user who is gaining the follower
I have two routes /follow which creates a record in the follows table and /unfollow which removes a record from the follow tables.
I'm trying to add two relationship properties to user.entity.ts
- followers : User [] all users that follow the user
- following: User [] all users the user is following
then just load these relations when I want to on a user like a profile on twitter.
I referenced this article but its in rails and HasMany doesnt seem to exist in typeorm. https://levelup.gitconnected.com/how-to-create-a-follow-unfollow-button-in-your-rails-social-media-application-e4081c279bca
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
