Files
backend/libs/common/src/modules/project/entities/project.entity.ts
2024-12-16 00:19:14 -06:00

40 lines
1.1 KiB
TypeScript

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<ProjectDto> {
@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<ProjectEntity>) {
super();
Object.assign(this, partial);
}
}