diff --git a/app/backend/src/user/entities/user.entity.ts b/app/backend/src/user/entities/user.entity.ts index be76c1f4..9496c1aa 100644 --- a/app/backend/src/user/entities/user.entity.ts +++ b/app/backend/src/user/entities/user.entity.ts @@ -8,6 +8,8 @@ import { BeforeUpdate, OneToMany, Relation, + JoinTable, + ManyToMany, } from 'typeorm'; const SALT_ROUNDS = 10; @@ -38,6 +40,14 @@ export class User { @OneToMany(() => Poll, poll => poll.creator) polls: Relation; + @ManyToMany(type => User, user => user.followings) + @JoinTable() + followers: User[]; + + @ManyToMany(type => User, user => user.followers) + followings: User[]; + + @BeforeInsert() async hashPasswordBeforeInsert() { if (this.password) {