Skip to content

Commit

Permalink
Merge pull request #306 from bounswe/be-284/add_many-to-many_relation
Browse files Browse the repository at this point in the history
BE-284: Create many to many relation between users
  • Loading branch information
BatuhanIlhan authored Nov 14, 2023
2 parents 22b2940 + 8e957f0 commit 9ab17ee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/backend/src/user/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
BeforeUpdate,
OneToMany,
Relation,
JoinTable,
ManyToMany,
} from 'typeorm';

const SALT_ROUNDS = 10;
Expand Down Expand Up @@ -38,6 +40,14 @@ export class User {
@OneToMany(() => Poll, poll => poll.creator)
polls: Relation<Poll[]>;

@ManyToMany(type => User, user => user.followings)
@JoinTable()
followers: User[];

@ManyToMany(type => User, user => user.followers)
followings: User[];


@BeforeInsert()
async hashPasswordBeforeInsert() {
if (this.password) {
Expand Down

0 comments on commit 9ab17ee

Please sign in to comment.