mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-24 20:59:28 +00:00
fix orderby
This commit is contained in:
@@ -62,7 +62,7 @@ export class CardsRepository {
|
||||
question = undefined,
|
||||
currentPage,
|
||||
itemsPerPage,
|
||||
orderBy,
|
||||
orderBy = 'updated-desc',
|
||||
}: GetAllCardsInDeckDto
|
||||
): Promise<PaginatedCardsWithGrade> {
|
||||
try {
|
||||
@@ -78,7 +78,7 @@ export class CardsRepository {
|
||||
},
|
||||
}
|
||||
|
||||
const { key, direction } = getOrderByObject(orderBy)
|
||||
const { key, direction } = getOrderByObject(orderBy) || {}
|
||||
|
||||
if (key === 'grade') {
|
||||
const start = (currentPage - 1) * itemsPerPage
|
||||
@@ -122,7 +122,7 @@ export class CardsRepository {
|
||||
const result = await this.prisma.$transaction([
|
||||
this.prisma.card.count({ where }),
|
||||
this.prisma.card.findMany({
|
||||
orderBy: createPrismaOrderBy(orderBy) || { updated: 'desc' },
|
||||
orderBy: createPrismaOrderBy(orderBy),
|
||||
where,
|
||||
include: {
|
||||
grades: {
|
||||
|
||||
Reference in New Issue
Block a user