Move software files one directory up, Readme
This commit is contained in:
53
backend/models/acts/band.model.ts
Normal file
53
backend/models/acts/band.model.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
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 { BandGenre } from "./bandGenre.model";
|
||||
import { Concert } from "./concert.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Band extends Model {
|
||||
@Column
|
||||
name: string
|
||||
|
||||
@Column
|
||||
foundingYear: number
|
||||
|
||||
@Column
|
||||
descriptionEn: string
|
||||
|
||||
@Column
|
||||
descriptionDe: string
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING,
|
||||
get(): Array<string> {
|
||||
return this.getDataValue('images').split(';')
|
||||
},
|
||||
set(value: Array<string>) {
|
||||
this.setDataValue('images', value.join(';'))
|
||||
}
|
||||
})
|
||||
images: Array<string>
|
||||
|
||||
@Column
|
||||
imageMembers: string
|
||||
|
||||
@Column
|
||||
logo: string
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@HasMany(() => Member)
|
||||
members: Member[]
|
||||
|
||||
@HasMany(() => Rating)
|
||||
ratings: Rating[]
|
||||
|
||||
@HasMany(() => Concert)
|
||||
concerts: Concert[]
|
||||
|
||||
@BelongsToMany(() => Genre, () => BandGenre)
|
||||
genres: Genre[]
|
||||
}
|
||||
16
backend/models/acts/bandGenre.model.ts
Normal file
16
backend/models/acts/bandGenre.model.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Column, ForeignKey, Model, PrimaryKey, Table } from "sequelize-typescript";
|
||||
import { Genre } from "./genre.model";
|
||||
import { Band } from "./band.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class BandGenre extends Model {
|
||||
@PrimaryKey
|
||||
@Column({autoIncrement: true})
|
||||
declare id: number
|
||||
|
||||
@ForeignKey(() => Genre)
|
||||
genreId: number
|
||||
|
||||
@ForeignKey(() => Band)
|
||||
bandId: number
|
||||
}
|
||||
45
backend/models/acts/concert.model.ts
Normal file
45
backend/models/acts/concert.model.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
|
||||
import { Location } from "../locations/location.model";
|
||||
import { Ticket } from "../ordering/ticket.model";
|
||||
import { Band } from "./band.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Concert extends Model {
|
||||
@Column
|
||||
date: string
|
||||
|
||||
@Column
|
||||
name: string
|
||||
|
||||
@Column
|
||||
price: number
|
||||
|
||||
@Column
|
||||
image: string
|
||||
|
||||
@Column
|
||||
inStock: number
|
||||
|
||||
@Column
|
||||
offered: boolean
|
||||
|
||||
@ForeignKey(() => Band)
|
||||
@Column
|
||||
bandId: number
|
||||
|
||||
@ForeignKey(() => Location)
|
||||
@Column
|
||||
locationId: number
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@BelongsTo(() => Band)
|
||||
band: Band
|
||||
|
||||
@BelongsTo(() => Location)
|
||||
location: Location
|
||||
|
||||
@HasMany(() => Ticket)
|
||||
tickets: Ticket[]
|
||||
}
|
||||
15
backend/models/acts/genre.model.ts
Normal file
15
backend/models/acts/genre.model.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { BelongsToMany, Column, Model, Table } from "sequelize-typescript";
|
||||
import { Band } from "./band.model";
|
||||
import { BandGenre } from "./bandGenre.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Genre extends Model {
|
||||
@Column
|
||||
name: string
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@BelongsToMany(() => Band, () => BandGenre)
|
||||
bands: Band[]
|
||||
}
|
||||
21
backend/models/acts/member.model.ts
Normal file
21
backend/models/acts/member.model.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { BelongsTo, Column, ForeignKey, Model, Table } from "sequelize-typescript";
|
||||
import { Band } from "./band.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Member extends Model {
|
||||
@Column
|
||||
name: string
|
||||
|
||||
@ForeignKey(() => Band)
|
||||
@Column
|
||||
bandId: number
|
||||
|
||||
@Column
|
||||
image: string
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@BelongsTo(() => Band)
|
||||
bands: Band[]
|
||||
}
|
||||
27
backend/models/acts/rating.model.ts
Normal file
27
backend/models/acts/rating.model.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { BelongsTo, Column, ForeignKey, Model, Table } from "sequelize-typescript";
|
||||
import { Account } from "../user/account.model";
|
||||
import { Band } from "./band.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Rating extends Model {
|
||||
|
||||
@ForeignKey(() => Account)
|
||||
@Column
|
||||
accountId: number
|
||||
|
||||
@Column
|
||||
rating: number
|
||||
|
||||
@ForeignKey(() => Band)
|
||||
@Column
|
||||
bandId: number
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@BelongsTo(() => Account)
|
||||
account: Account
|
||||
|
||||
@BelongsTo(() => Band)
|
||||
band: Band
|
||||
}
|
||||
Reference in New Issue
Block a user