Implement global search
This commit is contained in:
@@ -59,7 +59,7 @@ band.get("/", (req: Request, res: Response) => {
|
||||
})
|
||||
|
||||
// Get all information about one band
|
||||
band.get("/:name", (req: Request, res: Response) => {
|
||||
band.get("/band/:name", (req: Request, res: Response) => {
|
||||
Band.findOne({
|
||||
where: {
|
||||
name: { [Op.like]: req.params.name }
|
||||
@@ -109,4 +109,19 @@ band.get("/:name", (req: Request, res: Response) => {
|
||||
.then(band => {
|
||||
res.status(200).json(band)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// Band search
|
||||
band.get("/search", (req: Request, res: Response) => {
|
||||
Band.findAll({
|
||||
where: {
|
||||
name: {
|
||||
[Op.substring]: req.query.value
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(bands => {
|
||||
res.status(200).json(bands)
|
||||
})
|
||||
})
|
||||
@@ -8,10 +8,11 @@ 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()
|
||||
|
||||
concert.get("/:id", (req: Request, res: Response) => {
|
||||
concert.get("/concert/:id", (req: Request, res: Response) => {
|
||||
Concert.findByPk(req.params.id, {
|
||||
include: [
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Request, Response, Router } from "express";
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { Genre } from "../models/acts/genre.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
import { Op } from "sequelize";
|
||||
|
||||
export const events = Router()
|
||||
|
||||
@@ -80,5 +81,33 @@ events.get("/", async (req: Request, res: Response) => {
|
||||
|
||||
res.status(200).json(events)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// Event search
|
||||
events.get("/search", (req: Request, res: Response) => {
|
||||
Event.findAll({
|
||||
where: {
|
||||
name: {
|
||||
[Op.substring]: req.query.value
|
||||
}
|
||||
},
|
||||
include: [
|
||||
{
|
||||
model: Concert,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
model: Location,
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
model: Band,
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(events => {
|
||||
res.status(200).json(events)
|
||||
})
|
||||
})
|
||||
@@ -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()
|
||||
|
||||
@@ -69,7 +70,7 @@ location.get("/", (req: Request, res: Response) => {
|
||||
})
|
||||
})
|
||||
|
||||
location.get("/:urlName", (req: Request, res: Response) => {
|
||||
location.get("/location/:urlName", (req: Request, res: Response) => {
|
||||
Location.findOne({
|
||||
where: { urlName: req.params.urlName },
|
||||
include: [
|
||||
@@ -117,4 +118,19 @@ location.get("/:urlName", (req: Request, res: Response) => {
|
||||
|
||||
res.status(200).json(location)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// Location search
|
||||
location.get("/search", (req: Request, res: Response) => {
|
||||
Location.findAll({
|
||||
where: {
|
||||
name: {
|
||||
[Op.substring]: req.query.value
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(locations => {
|
||||
res.status(200).json(locations)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user