import { Entity, Column, Unique, OneToMany } from 'typeorm'; import { AbstractEntity } from '../../abstract/entities/abstract.entity'; import { ProjectDto } from '../dtos'; import { CommunityEntity } from '../../community/entities'; import { SpaceModelEntity } from '../../space-model'; import { UserEntity } from '../../user/entities'; @Entity({ name: 'project' }) @Unique(['name']) export class ProjectEntity extends AbstractEntity { @Column({ type: 'uuid', default: () => 'gen_random_uuid()', nullable: false, }) public uuid: string; @Column({ nullable: false, }) public name: string; @Column({ length: 255, nullable: true }) description: string; @OneToMany(() => SpaceModelEntity, (spaceModel) => spaceModel.project) public spaceModels: SpaceModelEntity[]; @OneToMany(() => CommunityEntity, (community) => community.project) communities: CommunityEntity[]; @OneToMany(() => UserEntity, (user) => user.project) public users: UserEntity[]; constructor(partial: Partial) { super(); Object.assign(this, partial); } }