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
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|
import { ProductEntity } from '../../product/entities/product.entity';
|
|
import { SpaceModelProductAllocationEntity } from '../../space-model/entities/space-model-product-allocation.entity';
|
|
import { NewTagEntity } from '../../tag/entities/tag.entity';
|
|
import { SpaceProductAllocationDto } from '../dtos/space-product-allocation.dto';
|
|
import { SpaceEntity } from './space.entity';
|
|
|
|
@Entity({ name: 'space_product_allocation' })
|
|
@Unique(['space', 'product', 'tag'], {})
|
|
export class SpaceProductAllocationEntity extends AbstractEntity<SpaceProductAllocationDto> {
|
|
@Column({
|
|
type: 'uuid',
|
|
default: () => 'gen_random_uuid()',
|
|
nullable: false,
|
|
})
|
|
public uuid: string;
|
|
|
|
@ManyToOne(() => SpaceEntity, (space) => space.productAllocations, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
})
|
|
public space: SpaceEntity;
|
|
|
|
@ManyToOne(() => SpaceModelProductAllocationEntity, {
|
|
nullable: true,
|
|
onDelete: 'SET NULL',
|
|
})
|
|
public inheritedFromModel?: SpaceModelProductAllocationEntity;
|
|
|
|
@ManyToOne(() => ProductEntity, { nullable: false, onDelete: 'CASCADE' })
|
|
public product: ProductEntity;
|
|
|
|
@ManyToOne(() => NewTagEntity, { nullable: true, onDelete: 'CASCADE' })
|
|
public tag: NewTagEntity;
|
|
|
|
constructor(partial: Partial<SpaceProductAllocationEntity>) {
|
|
super();
|
|
Object.assign(this, partial);
|
|
}
|
|
}
|