Implement global search

This commit is contained in:
2024-10-11 12:59:21 +02:00
parent 49b436d588
commit cfb8fb9d7d
24 changed files with 262 additions and 209 deletions

View File

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