From bf5e14f955b4f207005280a179d6a7312c799bc9 Mon Sep 17 00:00:00 2001 From: suk-6 Date: Thu, 26 Sep 2024 23:13:22 +0900 Subject: [PATCH] =?UTF-8?q?test(sort):=20Sort=20categories=20with=20'?= =?UTF-8?q?=EB=A6=AC=EB=B9=99'=20category=20at=20the=20front=20in=20Catego?= =?UTF-8?q?ryService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/category/category.service.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/category/category.service.ts b/src/modules/category/category.service.ts index f3a86ae..521fccd 100644 --- a/src/modules/category/category.service.ts +++ b/src/modules/category/category.service.ts @@ -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) {