mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 13:17:54 +00:00
added the relation between models and space
This commit is contained in:
@@ -11,6 +11,7 @@ import { SpaceModelDto } from '../dtos';
|
||||
import { SubspaceModelEntity } from './subspace-model.entity';
|
||||
import { SpaceProductModelEntity } from './space-product-model.entity';
|
||||
import { ProjectEntity } from '../../project/entities';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'space-model' })
|
||||
@Unique(['modelName', 'project'])
|
||||
@@ -53,4 +54,9 @@ export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
||||
},
|
||||
)
|
||||
public spaceProductModels: SpaceProductModelEntity[];
|
||||
|
||||
@OneToMany(() => SpaceEntity, (space) => space.spaceModel, {
|
||||
cascade: true,
|
||||
})
|
||||
public spaces: SpaceEntity[];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Entity, Column, ManyToOne } from 'typeorm';
|
||||
import { Entity, Column, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceProductItemModelDto } from '../dtos';
|
||||
import { SpaceProductModelEntity } from './space-product-model.entity';
|
||||
import { SpaceProductItemEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'space-product-item-model' })
|
||||
export class SpaceProductItemModelEntity extends AbstractEntity<SpaceProductItemModelDto> {
|
||||
@@ -18,4 +19,11 @@ export class SpaceProductItemModelEntity extends AbstractEntity<SpaceProductItem
|
||||
},
|
||||
)
|
||||
public spaceProductModel: SpaceProductModelEntity;
|
||||
|
||||
@OneToMany(
|
||||
() => SpaceProductItemEntity,
|
||||
(spaceProductItem) => spaceProductItem.spaceProductItemModel,
|
||||
{ cascade: true },
|
||||
)
|
||||
public items: SpaceProductItemEntity[];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ProductEntity } from '../../product/entities';
|
||||
import { SpaceModelEntity } from './space-model.entity';
|
||||
import { SpaceProductItemModelEntity } from './space-product-item.entity';
|
||||
import { SpaceProductModelDto } from '../dtos';
|
||||
import { SpaceProductEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'space-product-model' })
|
||||
export class SpaceProductModelEntity extends AbstractEntity<SpaceProductModelDto> {
|
||||
@@ -37,4 +38,13 @@ export class SpaceProductModelEntity extends AbstractEntity<SpaceProductModelDto
|
||||
},
|
||||
)
|
||||
public items: SpaceProductItemModelEntity[];
|
||||
|
||||
@OneToMany(
|
||||
() => SpaceProductEntity,
|
||||
(spaceProduct) => spaceProduct.spaceProductModel,
|
||||
{
|
||||
cascade: true,
|
||||
},
|
||||
)
|
||||
public spaceProducts: SpaceProductEntity[];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceModelEntity } from './space-model.entity';
|
||||
import { SubSpaceModelDto } from '../dtos';
|
||||
import { SubspaceEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'subspace-model' })
|
||||
@Unique(['subspaceName', 'spaceModel'])
|
||||
@@ -27,4 +28,9 @@ export class SubspaceModelEntity extends AbstractEntity<SubSpaceModelDto> {
|
||||
},
|
||||
)
|
||||
public spaceModel: SpaceModelEntity;
|
||||
|
||||
@OneToMany(() => SubspaceEntity, (space) => space.subSpaceModel, {
|
||||
cascade: true,
|
||||
})
|
||||
public spaces: SubspaceEntity[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user