From c58a77cb53fb1bb759098ad880ab649f620d21d5 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Wed, 7 Jan 2026 19:12:11 +0330 Subject: [PATCH] order foods and categories --- src/modules/foods/providers/category.service.ts | 3 ++- src/modules/foods/repositories/food.repository.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/foods/providers/category.service.ts b/src/modules/foods/providers/category.service.ts index cac0809..b5ea3af 100644 --- a/src/modules/foods/providers/category.service.ts +++ b/src/modules/foods/providers/category.service.ts @@ -37,7 +37,8 @@ export class CategoryService { if (!restaurant || !restaurant.id) { throw new NotFoundException(RestMessage.NOT_FOUND); } - return this.categoryRepository.find({ restaurant: restaurant, isActive: true }); + return this.categoryRepository.find( + { restaurant: restaurant, isActive: true }, { orderBy: { order: 'ASC' } }); } async findAllByRestaurantId(restId: string): Promise { diff --git a/src/modules/foods/repositories/food.repository.ts b/src/modules/foods/repositories/food.repository.ts index 171bf41..a731dd9 100644 --- a/src/modules/foods/repositories/food.repository.ts +++ b/src/modules/foods/repositories/food.repository.ts @@ -24,7 +24,7 @@ export class FoodRepository extends EntityRepository { * Supports: search (title/content), categoryId, isActive, ordering. */ async findAllPaginated(restId: string, opts: FindFoodsOpts = {}): Promise> { - const { page = 1, limit = 10, search, orderBy = 'createdAt', order = 'desc', categoryId, isActive } = opts; + const { page = 1, limit = 10, search, orderBy = 'order', order = 'ASC', categoryId, isActive } = opts; const offset = (page - 1) * limit;