mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 04:24:54 +00:00
aadded product item to space
This commit is contained in:
@ -0,0 +1,42 @@
|
||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
||||
import { DeviceEntity } from '@app/common/modules/device/entities';
|
||||
import { SubspaceModelEntity } from '@app/common/modules/space-model';
|
||||
import { Column, Entity, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { SubspaceDto } from '../../dtos';
|
||||
import { SpaceEntity } from '../space.entity';
|
||||
|
||||
@Entity({ name: 'subspace' })
|
||||
export class SubspaceEntity extends AbstractEntity<SubspaceDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public subspaceName: string;
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.subspaces, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'space_id' })
|
||||
space: SpaceEntity;
|
||||
|
||||
@OneToMany(() => DeviceEntity, (device) => device.subspace, {
|
||||
nullable: true,
|
||||
})
|
||||
devices: DeviceEntity[];
|
||||
|
||||
@ManyToOne(() => SubspaceModelEntity, { nullable: true })
|
||||
@JoinColumn({ name: 'subspace_model_uuid' })
|
||||
subSpaceModel?: SubspaceModelEntity;
|
||||
|
||||
constructor(partial: Partial<SubspaceEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user