feat(companies): Adding field to carrier/shipper query

This commit is contained in:
Josepablo C
2024-07-05 00:41:22 -06:00
parent 85c37a225d
commit cfa545b91c
3 changed files with 7 additions and 4 deletions

View File

@@ -340,8 +340,10 @@ This endpoint is part of /loads endpoint
- `GET /own` : Get own company data. - `GET /own` : Get own company data.
- `PATCH /own` : Update 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 - `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 /users/:companyId` : Get the list of users within a company.
- `GET /:id` : Get data from specific company. - `GET /:id` : Get data from specific company.

View File

@@ -1,7 +1,7 @@
"use strict"; "use strict";
const { ROOT_PATH, MODELS_PATH, HANDLERS_PATH, LIB_PATH } = process.env; const { ROOT_PATH, MODELS_PATH, HANDLERS_PATH, LIB_PATH } = process.env;
const { getModel } = require( `${ROOT_PATH}/${MODELS_PATH}` ); 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 { getPagination } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` );
const usersModel = getModel('users'); const usersModel = getModel('users');
@@ -61,6 +61,7 @@ async function getListByType( type , req ){
"truck_type", "truck_type",
"company_description" "company_description"
]; ];
const { $sort } = req.query;
const { elements , page } = getPagination( req.query ); const { elements , page } = getPagination( req.query );
let query_elements; let query_elements;
if( elements >= 100 ){ if( elements >= 100 ){
@@ -75,7 +76,7 @@ async function getListByType( type , req ){
filter.$and = andFilterList; 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; const data_list = queryVal.data;
for(let i=0; i<data_list.length; i++){ for(let i=0; i<data_list.length; i++){
data_list[i] = data_list[i].toObject(); data_list[i] = data_list[i].toObject();

View File

@@ -2,7 +2,7 @@
const { ROOT_PATH, LIB_PATH } = process.env; const { ROOT_PATH, LIB_PATH } = process.env;
const { getModel } = require( '../../../lib/Models' ); const { getModel } = require( '../../../lib/Models' );
const { getPagination } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` ); const { getPagination } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` );
const { GenericHandler } = require( '../../../lib/Handlers//Generic.handler.js' ); const { GenericHandler } = require( '../../../lib/Handlers/Generic.handler.js' );
const Model = getModel('loads'); const Model = getModel('loads');
const CompanyModel = getModel('companies'); const CompanyModel = getModel('companies');
const ProposalsModel = getModel('proposals'); const ProposalsModel = getModel('proposals');