music-collection/backend/src/album/album.entity.ts
Phill Pover a51fd6997e
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Failing after 54s
Music Collection CI Workflow / test (./frontend) (push) Failing after 37s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Has been skipped
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Has been skipped
Music Collection CI Workflow / deploy (push) Has been skipped
Added User and Authentication, refactored IDs to use UUID
2025-05-16 18:02:46 +01:00

35 lines
661 B
TypeScript

import {Entity, Column, OneToMany, PrimaryGeneratedColumn, Generated} from 'typeorm';
import { IsNotEmpty, IsString, IsOptional } from 'class-validator';
import { Song } from '../song/song.entity';
import { UUID } from 'crypto';
@Entity('album')
export class Album {
@PrimaryGeneratedColumn()
@Generated("uuid")
uuid: UUID;
@Column({ unique: true })
@IsString()
@IsNotEmpty()
title: string;
@Column()
@IsString()
@IsNotEmpty()
artist: string;
@Column()
@IsString()
@IsNotEmpty()
genre: string;
@IsOptional()
@OneToMany(() => Song, (song) => song.album, {
eager: true,
onDelete: 'CASCADE',
})
songs: Song[];
}