mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 02:36:19 +00:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { Entity, Column, ManyToOne, ManyToMany, JoinTable } from 'typeorm';
|
|
import { SpaceEntity } from './space.entity';
|
|
import { SpaceModelProductAllocationEntity } from '../../space-model';
|
|
import { ProductEntity } from '../../product/entities';
|
|
import { NewTagEntity } from '../../tag';
|
|
|
|
@Entity({ name: 'space_product_allocation' })
|
|
export class SpaceProductAllocationEntity {
|
|
@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;
|
|
|
|
@Column({ type: 'int', default: 1 })
|
|
public allowedQuantity: number;
|
|
|
|
@ManyToMany(() => NewTagEntity)
|
|
@JoinTable({ name: 'space_product_tags' })
|
|
public allowedTags: NewTagEntity[];
|
|
}
|