order foods and categories
This commit is contained in:
@@ -37,7 +37,8 @@ export class CategoryService {
|
|||||||
if (!restaurant || !restaurant.id) {
|
if (!restaurant || !restaurant.id) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
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<Category[]> {
|
async findAllByRestaurantId(restId: string): Promise<Category[]> {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class FoodRepository extends EntityRepository<Food> {
|
|||||||
* Supports: search (title/content), categoryId, isActive, ordering.
|
* Supports: search (title/content), categoryId, isActive, ordering.
|
||||||
*/
|
*/
|
||||||
async findAllPaginated(restId: string, opts: FindFoodsOpts = {}): Promise<PaginatedResult<Food>> {
|
async findAllPaginated(restId: string, opts: FindFoodsOpts = {}): Promise<PaginatedResult<Food>> {
|
||||||
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;
|
const offset = (page - 1) * limit;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user