New locationDetailPage displays concert in a location, new datasets, images, URL path changed

This commit is contained in:
2024-09-29 21:42:20 +02:00
parent 04678f9913
commit 142d574f78
39 changed files with 493 additions and 515 deletions

View File

@@ -1,17 +1,41 @@
import { Concert } from "../models/acts/concert.model";
import { City } from "../models/acts/city.model";
import { Location } from "../models/acts/location.model";
import { Request, Response, Router } from "express";
import { Tour } from "../models/acts/tour.model";
import { Band } from "../models/acts/band.model";
export const location = Router()
location.get("/", (req: Request, res: Response) => {
Location.findAll({
include: [ City ],
include: [
City,
{
model: Concert,
include: [ Tour ],
attributes: {
exclude: [ "locationId", "tourId" ]
}
}
],
attributes: {
exclude: [ "cityId" ]
}
})
.then(locations => {
.then(async locations => {
for (let location of locations) {
for (let concert of location.dataValues.concerts) {
let tour = concert.dataValues.tour
await Band.findByPk(tour.dataValues.bandId)
.then(band => {
tour.dataValues.bandName = band.dataValues.name
delete tour.dataValues.bandId
})
}
}
res.status(200).json(locations)
})
})