mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-14 18:05:48 +00:00
added project space model relation
This commit is contained in:
@ -2,6 +2,7 @@ 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';
|
||||
|
||||
@Entity({ name: 'project' })
|
||||
@Unique(['name'])
|
||||
@ -20,7 +21,10 @@ export class ProjectEntity extends AbstractEntity<ProjectDto> {
|
||||
|
||||
@Column({ length: 255, nullable: true })
|
||||
description: string;
|
||||
|
||||
|
||||
@OneToMany(() => SpaceModelEntity, (spaceModel) => spaceModel.project)
|
||||
public spaceModels: SpaceModelEntity[];
|
||||
|
||||
@OneToMany(() => CommunityEntity, (community) => community.project)
|
||||
communities: CommunityEntity[];
|
||||
|
||||
|
@ -1,10 +1,19 @@
|
||||
import { Entity, Column, OneToMany } from 'typeorm';
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
Unique,
|
||||
} from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceModelDto } from '../dtos';
|
||||
import { SubspaceModelEntity } from './subspace-model.entity';
|
||||
import { SpaceProductModelEntity } from './space-product-model.entity';
|
||||
import { ProjectEntity } from '../../project/entities';
|
||||
|
||||
@Entity({ name: 'space-model' })
|
||||
@Unique(['modelName', 'project'])
|
||||
export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
@ -18,6 +27,13 @@ export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
||||
})
|
||||
public modelName: string;
|
||||
|
||||
@ManyToOne(() => ProjectEntity, (project) => project.spaceModels, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'project_uuid' })
|
||||
public project: ProjectEntity;
|
||||
|
||||
@OneToMany(
|
||||
() => SubspaceModelEntity,
|
||||
(subspaceModel) => subspaceModel.spaceModel,
|
||||
|
Reference in New Issue
Block a user