Streamlined stores

This commit is contained in:
2024-10-22 18:47:27 +02:00
parent 3e53a606a6
commit 4e6be355ea
45 changed files with 384 additions and 387 deletions

View File

@@ -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)
})
})

View File

@@ -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)
})
})