mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
38 lines
900 B
TypeScript
38 lines
900 B
TypeScript
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
|
|
import { AutomationDto } from '../dtos';
|
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|
import { SpaceEntity } from '../../space/entities/space.entity';
|
|
|
|
@Entity({ name: 'automation' })
|
|
export class AutomationEntity extends AbstractEntity<AutomationDto> {
|
|
@Column({
|
|
type: 'uuid',
|
|
default: () => 'gen_random_uuid()',
|
|
nullable: false,
|
|
})
|
|
public uuid: string;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
})
|
|
automationTuyaUuid: string;
|
|
|
|
@ManyToOne(() => SpaceEntity, (space) => space.scenes, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'space_uuid' })
|
|
space: SpaceEntity;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
default: false,
|
|
})
|
|
public disabled: boolean;
|
|
|
|
constructor(partial: Partial<AutomationEntity>) {
|
|
super();
|
|
Object.assign(this, partial);
|
|
}
|
|
}
|