homemanager-be/src/objects/storage/entities/storage-set.entity.ts

68 lines
1.3 KiB
TypeScript

import { ApiProperty } from '@nestjs/swagger';
import { Room } from 'src/objects/building/entities/room.entity';
import { User } from 'src/objects/user/user.entity';
import {
Column,
CreateDateColumn,
Entity,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { StorageSetType } from '../enums/storage-set-type.enum';
import { Storage } from './storage.entity';
@Entity()
export class StorageSet {
@ApiProperty()
@PrimaryGeneratedColumn()
id: number;
@ApiProperty()
@Column()
displayName: string;
@ApiProperty({ type: () => Room })
@ManyToOne(() => Room, {
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
})
room: Room;
@ApiProperty({ type: String, enum: StorageSetType })
@Column({ type: String })
type: StorageSetType;
@ApiProperty()
@Column()
location: string;
@ApiProperty()
@Column()
locationDescription: string;
@ApiProperty()
@Column()
color: string;
@ApiProperty({ type: () => Storage, isArray: true })
@OneToMany(() => Storage, (storage) => storage.set)
storages: Storage[];
@ApiProperty({ type: () => User })
@ManyToOne(() => User, {
onDelete: 'SET NULL',
nullable: true,
})
addedBy: User;
@ApiProperty()
@CreateDateColumn()
createdAt: Date;
@ApiProperty()
@UpdateDateColumn()
updatedAt: Date;
}