community user relation

This commit is contained in:
hannathkadher
2024-10-15 12:04:54 +04:00
parent d14d3b5ba2
commit b8d4a080ef
2 changed files with 24 additions and 1 deletions

View File

@ -1,8 +1,16 @@
import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
import {
Column,
Entity,
ManyToMany,
ManyToOne,
OneToMany,
Unique,
} from 'typeorm';
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
import { CommunityDto } from '../dtos';
import { RegionEntity } from '../../region/entities';
import { SpaceEntity } from '../../space/entities';
import { UserEntity } from '../../user/entities';
@Entity({ name: 'community' })
@Unique(['name'])
@ -31,4 +39,7 @@ export class CommunityEntity extends AbstractEntity<CommunityDto> {
@OneToMany(() => SpaceEntity, (space) => space.community)
spaces: SpaceEntity[];
@ManyToMany(() => UserEntity, (user) => user.communities)
users: UserEntity[];
}