import { Column, Entity, ManyToOne, Unique } from 'typeorm'; import { AbstractEntity } from '../../abstract/entities/abstract.entity'; import { PresenceSensorDto } from '../dtos'; import { DeviceEntity } from '../../device/entities/device.entity'; import { SpaceEntity } from '../../space/entities/space.entity'; @Entity({ name: 'presence-sensor-daily-device-detection' }) @Unique(['deviceUuid', 'eventDate']) export class PresenceSensorDailyDeviceEntity extends AbstractEntity { @Column({ nullable: false }) public deviceUuid: string; @Column({ nullable: false, type: 'date' }) public eventDate: string; @Column({ nullable: false }) public CountMotionDetected: number; @Column({ nullable: false }) public CountPresenceDetected: number; @Column({ nullable: false }) public CountTotalPresenceDetected: number; @ManyToOne(() => DeviceEntity, (device) => device.presenceSensorDaily) device: DeviceEntity; constructor(partial: Partial) { super(); Object.assign(this, partial); } } @Entity({ name: 'presence-sensor-daily-space-detection' }) @Unique(['spaceUuid', 'eventDate']) export class PresenceSensorDailySpaceEntity extends AbstractEntity { @Column({ nullable: false }) public spaceUuid: string; @Column({ nullable: false, type: 'date' }) public eventDate: string; @Column({ nullable: false }) public CountMotionDetected: number; @Column({ nullable: false }) public CountPresenceDetected: number; @Column({ nullable: false }) public CountTotalPresenceDetected: number; @ManyToOne(() => SpaceEntity, (space) => space.presenceSensorDaily) space: SpaceEntity; constructor(partial: Partial) { super(); Object.assign(this, partial); } }