diff --git a/README.md b/README.md index 0e88c67..ba094ab 100644 --- a/README.md +++ b/README.md @@ -340,8 +340,10 @@ This endpoint is part of /loads endpoint - `GET /own` : Get own company data. - `PATCH /own` : Update own company data. - - `GET /shipper` : Get list of shipper companies with pagination using the following filters: company_type, company_name, truck_type, categories, company_state, company_city + - `GET /shipper` : Get list of shipper companies with pagination using the following filters: company_type, company_name, truck_type, categories, company_state, company_city. + - $sort[ field ] : -1/1 ; Sort result by field name - `GET /carrier` : Get list of carrier companies with pagination using the following filters: company_type, company_name, truck_type, categories, company_state, company_city + - $sort[ field ] : -1/1 ; Sort result by field name - `GET /users/:companyId` : Get the list of users within a company. - `GET /:id` : Get data from specific company. diff --git a/src/apps/private/companies/services.js b/src/apps/private/companies/services.js index 4aea62d..82ca2a9 100644 --- a/src/apps/private/companies/services.js +++ b/src/apps/private/companies/services.js @@ -1,7 +1,7 @@ "use strict"; const { ROOT_PATH, MODELS_PATH, HANDLERS_PATH, LIB_PATH } = process.env; const { getModel } = require( `${ROOT_PATH}/${MODELS_PATH}` ); -const { GenericHandler } = require( `${ROOT_PATH}/${HANDLERS_PATH}/Generic.handler.js` ); +const { GenericHandler } = require( '../../../lib/Handlers/Generic.handler.js' ); const { getPagination } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` ); const usersModel = getModel('users'); @@ -61,6 +61,7 @@ async function getListByType( type , req ){ "truck_type", "company_description" ]; + const { $sort } = req.query; const { elements , page } = getPagination( req.query ); let query_elements; if( elements >= 100 ){ @@ -75,7 +76,7 @@ async function getListByType( type , req ){ filter.$and = andFilterList; } - const queryVal = await generic.getList(page , query_elements, filter, select ); + const queryVal = await generic.getList(page , query_elements, filter, select, $sort ); const data_list = queryVal.data; for(let i=0; i