mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 02:36:19 +00:00
community controller
This commit is contained in:
@ -0,0 +1,38 @@
|
||||
import { Column, Entity, 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 { RoleEntity } from '../../role/entities';
|
||||
|
||||
@Entity({ name: 'community' })
|
||||
@Unique(['name'])
|
||||
export class CommunityEntity extends AbstractEntity<CommunityDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
length: 255,
|
||||
nullable: false,
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({ length: 255, nullable: true })
|
||||
description: string;
|
||||
|
||||
@ManyToOne(() => RegionEntity, (region) => region.communities, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
region: RegionEntity;
|
||||
|
||||
@OneToMany(() => SpaceEntity, (space) => space.community)
|
||||
spaces: SpaceEntity[];
|
||||
|
||||
@OneToMany(() => RoleEntity, (role) => role.community)
|
||||
roles: RoleEntity[];
|
||||
}
|
Reference in New Issue
Block a user