Streamlined stores
This commit is contained in:
@@ -7,6 +7,7 @@ import { SeatRow } from "../models/locations/seatRow.model";
|
||||
import { Seat } from "../models/locations/seat.model";
|
||||
import { Ticket } from "../models/ordering/ticket.model";
|
||||
import { Band } from "../models/acts/band.model";
|
||||
import { Op } from "sequelize";
|
||||
|
||||
export const concert = Router()
|
||||
|
||||
@@ -95,3 +96,19 @@ concert.get("/concert/:id", (req: Request, res: Response) => {
|
||||
res.status(200).json(concert)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// Concert search
|
||||
concert.get("/search", (req: Request, res: Response) => {
|
||||
Concert.findAll({
|
||||
where: {
|
||||
name: {
|
||||
[Op.substring]: req.query.value
|
||||
}
|
||||
},
|
||||
include: [ Band, Location ]
|
||||
})
|
||||
.then(concerts => {
|
||||
res.status(200).json(concerts)
|
||||
})
|
||||
})
|
||||
@@ -93,13 +93,23 @@ location.get("/location/:urlName", (req: Request, res: Response) => {
|
||||
location.get("/search", (req: Request, res: Response) => {
|
||||
Location.findAll({
|
||||
where: {
|
||||
name: {
|
||||
[Op.substring]: req.query.value
|
||||
}
|
||||
[Op.or]: [
|
||||
{
|
||||
name: {
|
||||
[Op.substring]: req.query.value
|
||||
},
|
||||
},
|
||||
{
|
||||
"$city.name$": {
|
||||
[Op.substring]: req.query.value
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
include: [ Concert ]
|
||||
include: [ City, Concert ]
|
||||
})
|
||||
.then(locations => {
|
||||
console.log(locations)
|
||||
res.status(200).json(locations)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user