Display all bands grouped by genre, create m:n association between Band and Genre in database
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
import { Rating } from "../models/acts/rating.model";
|
||||
import { Band } from "../models/acts/band.model";
|
||||
import { Genre } from "../models/acts/genre.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
export const genre = Router()
|
||||
|
||||
genre.get("/", (req: Request, res: Response) => {
|
||||
Genre.findAll()
|
||||
Genre.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Band,
|
||||
include: [ Rating ]
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(genres => {
|
||||
res.status(200).json(genres)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user