mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
added subspace and space product allocation entity
This commit is contained in:
@ -0,0 +1,37 @@
|
||||
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[];
|
||||
}
|
Reference in New Issue
Block a user