From d2e020de9c0839654c3baa6f5d016228c4b49312 Mon Sep 17 00:00:00 2001 From: huydo862003 Date: Mon, 18 Dec 2023 16:46:50 +0700 Subject: [PATCH] fix: support ordering on boughtAmount field --- src/dtos/in/defaultModel.dto.ts | 17 +++++++++++++---- src/handlers/defaultModel.handler.ts | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/dtos/in/defaultModel.dto.ts b/src/dtos/in/defaultModel.dto.ts index 45e9a91..8004ada 100644 --- a/src/dtos/in/defaultModel.dto.ts +++ b/src/dtos/in/defaultModel.dto.ts @@ -25,10 +25,19 @@ export const DefaultModelQueryStringDto = Type.Object({ Type.Number({ minimum: 1, multipleOf: 1, description: 'For pagination purpose - the number of items to return' }) ), orderBy: Type.Optional( - Type.Union([Type.Literal('likesNo'), Type.Literal('uploadedTime'), Type.Literal('price'), Type.Literal('name')], { - description: 'The name of the field to order on', - examples: ['likesNo', 'uploadedTime', 'price', 'name'] - }) + Type.Union( + [ + Type.Literal('likesNo'), + Type.Literal('uploadedTime'), + Type.Literal('price'), + Type.Literal('name'), + Type.Literal('numberBought') + ], + { + description: 'The name of the field to order on', + examples: ['likesNo', 'uploadedTime', 'price', 'name', 'numberBought'] + } + ) ), order: Type.Optional( Type.Union([Type.Literal('asc'), Type.Literal('desc')], { description: 'Sort ascending or descending', examples: ['asc', 'desc'] }) diff --git a/src/handlers/defaultModel.handler.ts b/src/handlers/defaultModel.handler.ts index 59d88a7..04d4d24 100644 --- a/src/handlers/defaultModel.handler.ts +++ b/src/handlers/defaultModel.handler.ts @@ -55,7 +55,8 @@ const getAll: Handler