fix(v1:vehicles): company_name comes from company.company_name

This commit is contained in:
Josepablo C
2024-08-16 21:11:12 -06:00
parent 593d6f6143
commit bed21badb9
2 changed files with 6 additions and 7 deletions

View File

@@ -1,8 +1,7 @@
"use strict";
const { ROOT_PATH, LIB_PATH, MODELS_PATH, HANDLERS_PATH } = process.env;
const { getModel } = require( `${ROOT_PATH}/${MODELS_PATH}` );
const { getPagination } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` );
const { GenericHandler } = require( `${ROOT_PATH}/${HANDLERS_PATH}/Generic.handler.js` );
const { getModel } = require( '../../../lib/Models' );
const { getPagination } = require( '../../../lib/Misc' );
const { GenericHandler } = require( '../../../lib/Handlers/Generic.handler' );
const Model = getModel('vehicles');
const CompanyModel = getModel('companies');
@@ -152,7 +151,7 @@ const patchVehicle = async(req, res) => {
}
data.company = companyId;
data.company_name = company.name;
data.company_name = company.company_name;
await Model.findByIdAndUpdate( elementId , data );
return res.send( await Model.findById( elementId ) );
}catch(error){
@@ -176,7 +175,7 @@ const postVehicle = async(req, res) => {
}
data.company = companyId;
data.company_name = company.name;
data.company_name = company.company_name;
data.status = "Free";
data.is_available = false;
data.posted_by = userId;

View File

@@ -15,7 +15,7 @@ const pointSchema = new Schema({
const schema = new Schema({
company: { type: Schema.Types.ObjectId, ref: 'companies', required: true }, // carrier
company_name : { type: String },
company_name : { type: String, required: true },
vehicle_code: { type: String },
vehicle_name: { type: String },