Skip to content

Commit

Permalink
test(sort): Sort categories with '리빙' category at the front in Catego…
Browse files Browse the repository at this point in the history
…ryService
  • Loading branch information
suk-6 committed Sep 26, 2024
1 parent 29c9c56 commit bf5e14f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/modules/category/category.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ export class CategoryService {
constructor(private readonly prisma: PrismaService) {}

async getCategories() {
return this.prisma.category.findMany({
select: { id: true, name: true },
});
return (
this.prisma.category
.findMany({
select: { id: true, name: true },
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.then((categories) => categories.sort((a, _) => (a.name === '리빙' ? -1 : 1))) // 리빙 카테고리를 가장 앞으로
);
}

async getProductsByCategoryId(categoryId: string) {
Expand Down

0 comments on commit bf5e14f

Please sign in to comment.