Display all bands grouped by genre, create m:n association between Band and Genre in database

This commit is contained in:
2024-09-27 23:25:24 +02:00
parent 848e7abf92
commit 9b325c849e
29 changed files with 275 additions and 165 deletions

View File

@@ -1,8 +1,9 @@
import { BelongsTo, Column, DataType, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
import { BelongsTo, BelongsToMany, Column, DataType, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
import { Member } from "./member.model";
import { Genre } from "./genre.model";
import { Rating } from "./rating.model";
import { Tour } from "./tour.model";
import { BandGenre } from "./bandGenre.model";
@Table({ timestamps: false })
export class Band extends Model {
@@ -32,10 +33,6 @@ export class Band extends Model {
@Column
logo: String
@ForeignKey(() => Genre)
@Column
genreId: Number
// Relations
@@ -48,6 +45,6 @@ export class Band extends Model {
@HasMany(() => Tour)
tours: Tour[]
@BelongsTo(() => Genre)
genre: Genre
@BelongsToMany(() => Genre, () => BandGenre)
genres: Genre[]
}