mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 11:15:14 +00:00
added community space
This commit is contained in:
@ -3,7 +3,6 @@ import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { CommunityDto } from '../dtos';
|
||||
import { RegionEntity } from '../../region/entities';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
import { RoleEntity } from '../../role/entities';
|
||||
|
||||
@Entity({ name: 'community' })
|
||||
@Unique(['name'])
|
||||
@ -32,7 +31,4 @@ export class CommunityEntity extends AbstractEntity<CommunityDto> {
|
||||
|
||||
@OneToMany(() => SpaceEntity, (space) => space.community)
|
||||
spaces: SpaceEntity[];
|
||||
|
||||
@OneToMany(() => RoleEntity, (role) => role.community)
|
||||
roles: RoleEntity[];
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { RegionDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
import { CommunityEntity } from '../../community/entities';
|
||||
|
||||
@Entity({ name: 'region' })
|
||||
export class RegionEntity extends AbstractEntity<RegionDto> {
|
||||
@ -13,6 +14,9 @@ export class RegionEntity extends AbstractEntity<RegionDto> {
|
||||
@OneToMany(() => UserEntity, (user) => user.region)
|
||||
users: UserEntity[];
|
||||
|
||||
@OneToMany(() => CommunityEntity, (community) => community.region)
|
||||
communities: CommunityEntity[];
|
||||
|
||||
constructor(partial: Partial<RegionEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
@ -1,8 +1,16 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
Unique,
|
||||
} from 'typeorm';
|
||||
import { SpaceDto, SpaceTypeDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserSpaceEntity } from '../../user/entities';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import { CommunityEntity } from '../../community/entities';
|
||||
|
||||
@Entity({ name: 'space-type' })
|
||||
export class SpaceTypeEntity extends AbstractEntity<SpaceTypeDto> {
|
||||
@ -45,6 +53,13 @@ export class SpaceEntity extends AbstractEntity<SpaceDto> {
|
||||
})
|
||||
public spaceName: string;
|
||||
|
||||
@ManyToOne(() => CommunityEntity, (community) => community.spaces, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'community_id' })
|
||||
community: CommunityEntity;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
})
|
||||
|
Reference in New Issue
Block a user