Listory/src/music-library/album.entity.ts

31 lines
672 B
TypeScript
Raw Normal View History

2020-02-02 19:21:58 +01:00
import {
Column,
2020-09-05 21:07:05 +02:00
Entity,
2020-02-02 19:21:58 +01:00
JoinTable,
2020-09-05 21:07:05 +02:00
ManyToMany,
2020-05-02 17:17:20 +02:00
OneToMany,
2020-09-05 21:07:05 +02:00
PrimaryGeneratedColumn,
2020-02-02 19:21:58 +01:00
} from "typeorm";
2020-09-05 21:07:05 +02:00
import { SpotifyLibraryDetails } from "../sources/spotify/spotify-library-details.entity";
2020-02-02 19:21:58 +01:00
import { Artist } from "./artist.entity";
import { Track } from "./track.entity";
@Entity()
export class Album {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column()
name: string;
2020-05-02 17:17:20 +02:00
@ManyToMany((type) => Artist, (artist) => artist.albums)
2020-05-03 20:18:42 +02:00
@JoinTable({ name: "album_artists" })
artists?: Artist[];
2020-02-02 19:21:58 +01:00
2020-05-02 17:17:20 +02:00
@OneToMany((type) => Track, (track) => track.album)
tracks?: Track[];
2020-02-02 19:21:58 +01:00
2020-05-02 17:17:20 +02:00
@Column((type) => SpotifyLibraryDetails)
2020-02-02 19:21:58 +01:00
spotify: SpotifyLibraryDetails;
}