mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 02:15:21 +00:00

* refactor: reducing used queries on get communities (#385) * refactor: fix create space logic (#394) * Remove unique constraint on subspace and product in SubspaceProductAllocationEntity; update product relation to nullable in NewTagEntity * refactor: fix create space logic * device model updated to include the fixes and final columns * updated space models to include suggested fixes, update final logic and column names * task: removing old references of the old tag-product relation * task: remove old use of tags * task: remove old tag & tag model usage * refactor: delete space * task: remove unused functions * fix lint rule
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
import { Column, Entity, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
|
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|
import { ProjectEntity } from '../../project/entities';
|
|
import { SpaceEntity } from '../../space/entities/space.entity';
|
|
import { SpaceModelDto } from '../dtos';
|
|
import { SpaceModelProductAllocationEntity } from './space-model-product-allocation.entity';
|
|
import { SubspaceModelEntity } from './subspace-model';
|
|
|
|
@Entity({ name: 'space-model' })
|
|
export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
|
@Column({
|
|
type: 'uuid',
|
|
default: () => 'gen_random_uuid()',
|
|
nullable: false,
|
|
})
|
|
public uuid: string;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
})
|
|
public modelName: string;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
default: false,
|
|
})
|
|
public disabled: boolean;
|
|
|
|
@ManyToOne(() => ProjectEntity, (project) => project.spaceModels, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'project_uuid' })
|
|
public project: ProjectEntity;
|
|
|
|
@OneToMany(
|
|
() => SubspaceModelEntity,
|
|
(subspaceModel) => subspaceModel.spaceModel,
|
|
{
|
|
cascade: true,
|
|
nullable: true,
|
|
},
|
|
)
|
|
public subspaceModels: SubspaceModelEntity[];
|
|
|
|
@OneToMany(() => SpaceEntity, (space) => space.spaceModel, {
|
|
cascade: true,
|
|
})
|
|
public spaces: SpaceEntity[];
|
|
|
|
@OneToMany(
|
|
() => SpaceModelProductAllocationEntity,
|
|
(allocation) => allocation.spaceModel,
|
|
{ cascade: true },
|
|
)
|
|
public productAllocations: SpaceModelProductAllocationEntity[];
|
|
|
|
constructor(partial: Partial<SpaceModelEntity>) {
|
|
super();
|
|
Object.assign(this, partial);
|
|
}
|
|
}
|