fix orderBy not allowing null

This commit is contained in:
andres
2023-08-12 13:42:44 +02:00
parent e615fe7711
commit 2626bf3815
4 changed files with 4 additions and 6 deletions

View File

@@ -25,7 +25,6 @@ import {
import { JwtAuthGuard } from '../auth/guards'
import { CardsService } from './cards.service'
import { UpdateCardDto } from './dto'
import { Card } from './entities/cards.entity'
import { DeleteCardByIdCommand, GetDeckByIdCommand, UpdateCardCommand } from './use-cases'
@@ -33,7 +32,7 @@ import { DeleteCardByIdCommand, GetDeckByIdCommand, UpdateCardCommand } from './
@ApiTags('Cards')
@Controller('cards')
export class CardsController {
constructor(private readonly decksService: CardsService, private commandBus: CommandBus) {}
constructor(private commandBus: CommandBus) {}
@UseGuards(JwtAuthGuard)
@ApiOperation({ summary: 'Get card by id', description: 'Get card by id' })

View File

@@ -65,7 +65,7 @@ export class CardsRepository {
orderBy,
}: GetAllCardsInDeckDto
): Promise<PaginatedCardsWithGrade> {
if (!orderBy) {
if (!orderBy || orderBy === 'null') {
orderBy = 'updated-desc'
}
try {

View File

@@ -33,7 +33,6 @@ import { JwtAuthGuard } from '../auth/guards'
import { CreateCardDto, GetAllCardsInDeckDto } from '../cards/dto'
import { Card, PaginatedCards } from '../cards/entities/cards.entity'
import { DecksService } from './decks.service'
import { CreateDeckDto, GetAllDecksDto, UpdateDeckDto } from './dto'
import { GetRandomCardDto } from './dto/get-random-card.dto'
import { Deck, DeckWithAuthor, PaginatedDecks } from './entities/deck.entity'
@@ -52,7 +51,7 @@ import {
@ApiTags('Decks')
@Controller('decks')
export class DecksController {
constructor(private readonly decksService: DecksService, private commandBus: CommandBus) {}
constructor(private commandBus: CommandBus) {}
@HttpCode(HttpStatus.PARTIAL_CONTENT)
@ApiOperation({ description: 'Retrieve paginated decks list.', summary: 'Paginated decks list' })

View File

@@ -61,7 +61,7 @@ export class DecksRepository {
maxCardsCount,
orderBy,
}: GetAllDecksDto): Promise<PaginatedDecks> {
if (!orderBy) {
if (!orderBy || orderBy === 'null') {
orderBy = 'updated-desc'
}
try {