New locationDetailPage displays concert in a location, new datasets, images, URL path changed
This commit is contained in:
@@ -1,14 +1,26 @@
|
||||
import { Location } from "../models/acts/location.model";
|
||||
import { City } from "../models/acts/city.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Concert } from "../models/acts/concert.model";
|
||||
|
||||
export const city = Router()
|
||||
|
||||
city.get("/", (req: Request, res: Response) => {
|
||||
City.findAll({
|
||||
include: [ Location ]
|
||||
include: [
|
||||
{
|
||||
model: Location,
|
||||
include: [ Concert ]
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(cities => {
|
||||
for (let city of cities) {
|
||||
for (let location of city.dataValues.locations) {
|
||||
location.dataValues.nrOfConcerts = location.dataValues.concerts.length
|
||||
delete location.dataValues.concerts
|
||||
}
|
||||
}
|
||||
res.status(200).json(cities)
|
||||
})
|
||||
})
|
||||
@@ -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