mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
40 lines
1.1 KiB
TypeScript
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);
|
|
}
|
|
}
|