New locationDetailPage displays concert in a location, new datasets, images, URL path changed
This commit is contained in:
@@ -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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user