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 { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { ProjectDto } from '../dtos';
|
import { ProjectDto } from '../dtos';
|
||||||
import { CommunityEntity } from '../../community/entities';
|
import { CommunityEntity } from '../../community/entities';
|
||||||
|
import { SpaceModelEntity } from '../../space-model';
|
||||||
|
|
||||||
@Entity({ name: 'project' })
|
@Entity({ name: 'project' })
|
||||||
@Unique(['name'])
|
@Unique(['name'])
|
||||||
@ -20,7 +21,10 @@ export class ProjectEntity extends AbstractEntity<ProjectDto> {
|
|||||||
|
|
||||||
@Column({ length: 255, nullable: true })
|
@Column({ length: 255, nullable: true })
|
||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
|
@OneToMany(() => SpaceModelEntity, (spaceModel) => spaceModel.project)
|
||||||
|
public spaceModels: SpaceModelEntity[];
|
||||||
|
|
||||||
@OneToMany(() => CommunityEntity, (community) => community.project)
|
@OneToMany(() => CommunityEntity, (community) => community.project)
|
||||||
communities: CommunityEntity[];
|
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 { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { SpaceModelDto } from '../dtos';
|
import { SpaceModelDto } from '../dtos';
|
||||||
import { SubspaceModelEntity } from './subspace-model.entity';
|
import { SubspaceModelEntity } from './subspace-model.entity';
|
||||||
import { SpaceProductModelEntity } from './space-product-model.entity';
|
import { SpaceProductModelEntity } from './space-product-model.entity';
|
||||||
|
import { ProjectEntity } from '../../project/entities';
|
||||||
|
|
||||||
@Entity({ name: 'space-model' })
|
@Entity({ name: 'space-model' })
|
||||||
|
@Unique(['modelName', 'project'])
|
||||||
export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
||||||
@Column({
|
@Column({
|
||||||
type: 'uuid',
|
type: 'uuid',
|
||||||
@ -18,6 +27,13 @@ export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
|||||||
})
|
})
|
||||||
public modelName: string;
|
public modelName: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => ProjectEntity, (project) => project.spaceModels, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
})
|
||||||
|
@JoinColumn({ name: 'project_uuid' })
|
||||||
|
public project: ProjectEntity;
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
() => SubspaceModelEntity,
|
() => SubspaceModelEntity,
|
||||||
(subspaceModel) => subspaceModel.spaceModel,
|
(subspaceModel) => subspaceModel.spaceModel,
|
||||||
|
Reference in New Issue
Block a user