Skeleton loader
This commit is contained in:
@@ -7,6 +7,7 @@ import { Band } from "../models/acts/band.model";
|
||||
import { SeatGroup } from "../models/locations/seatGroup.model";
|
||||
import { Seat } from "../models/locations/seat.model";
|
||||
import { SeatRow } from "../models/locations/seatRow.model";
|
||||
import { Op } from "sequelize";
|
||||
|
||||
export const location = Router()
|
||||
|
||||
@@ -50,4 +51,47 @@ location.get("/", (req: Request, res: Response) => {
|
||||
|
||||
res.status(200).json(locations)
|
||||
})
|
||||
})
|
||||
|
||||
location.get("/:name", (req: Request, res: Response) => {
|
||||
console.log(req.params.name)
|
||||
|
||||
Location.findOne({
|
||||
where: { name: { [Op.like]: req.params.name } },
|
||||
include: [
|
||||
City,
|
||||
{
|
||||
model: Concert,
|
||||
include: [ Event ],
|
||||
attributes: {
|
||||
exclude: [ "locationId", "tourId" ]
|
||||
}
|
||||
},
|
||||
{
|
||||
model: SeatGroup,
|
||||
include: [
|
||||
{
|
||||
model: SeatRow,
|
||||
include: [ Seat ]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
attributes: {
|
||||
exclude: [ "cityId" ]
|
||||
}
|
||||
})
|
||||
.then(async location => {
|
||||
for (let concert of location.dataValues.concerts) {
|
||||
let event = concert.dataValues.event
|
||||
|
||||
await Band.findByPk(event.dataValues.bandId)
|
||||
.then(band => {
|
||||
event.dataValues.bandName = band.dataValues.name
|
||||
delete event.dataValues.bandId
|
||||
})
|
||||
}
|
||||
|
||||
res.status(200).json(location)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user