Update games service to include find by gametype

This commit is contained in:
Anthony Mineo 2020-08-29 18:36:24 -04:00
parent 38fb66da06
commit 75f6e64a1f
2 changed files with 9 additions and 2 deletions

View file

@ -14,7 +14,7 @@ export class GamesController {
return this.gameService.findAll({ limit, offset });
}
// /gametype/:gameId
// /gametype/:gametype
@Get('gametype/:gametype')
findByType(@Param('gametype') gametype: string) {
return this.gameService.findByType(gametype);

View file

@ -28,7 +28,14 @@ export class GamesService {
}
async findByType(gametype: string) {
const game = await this.gamesRepository.find({ where: { gametype: gametype } });
const game = await this.gamesRepository.find({
where: { gametype: gametype },
skip: 0,
take: 10,
order: {
gameId: 'DESC'
}
});
if (!game) {
throw new NotFoundException(`Game Type: ${gametype} not found`);
}