mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 02:17:54 +00:00
35 lines
868 B
TypeScript
35 lines
868 B
TypeScript
import { Column, Entity, OneToMany } from 'typeorm';
|
|
import { GroupDto } from '../dtos';
|
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|
import { GroupDeviceEntity } from '../../group-device/entities';
|
|
|
|
@Entity({ name: 'group' })
|
|
export class GroupEntity extends AbstractEntity<GroupDto> {
|
|
@Column({
|
|
type: 'uuid',
|
|
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
|
nullable: false,
|
|
})
|
|
public uuid: string;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
})
|
|
public groupName: string;
|
|
|
|
@OneToMany(() => GroupDeviceEntity, (groupDevice) => groupDevice.group, {
|
|
cascade: true,
|
|
})
|
|
groupDevices: GroupDeviceEntity[];
|
|
|
|
@Column({
|
|
nullable: true,
|
|
default: true,
|
|
})
|
|
public isActive: boolean;
|
|
constructor(partial: Partial<GroupEntity>) {
|
|
super();
|
|
Object.assign(this, partial);
|
|
}
|
|
}
|