fix(Model(vehicles)): available_in is a string now
This commit is contained in:
@@ -7,9 +7,12 @@ const vehicle_projection = ['background_tracking','status','last_location_lat',
|
||||
|
||||
const user_projection = ['first_name','last_name','middle_name']
|
||||
|
||||
const company_projection = ["company_name"]
|
||||
|
||||
const populate_list = [
|
||||
{path:'posted_by',select: user_projection },
|
||||
{path:'vehicle',select: vehicle_projection },
|
||||
{path:'company',select: company_projection },
|
||||
'posted_by_name',
|
||||
'categories'
|
||||
];
|
||||
@@ -36,7 +39,13 @@ const getById = async(req, res) => {
|
||||
];
|
||||
// const load = await Model.findOne( { _id : elementId , load_status : "Transit" } , select ).populate( populate_list );
|
||||
const load = await Model.findById( elementId , select ).populate( populate_list );
|
||||
res.send( load );
|
||||
if( load ){
|
||||
return res.send( load );
|
||||
}else{
|
||||
return res.status(400).send({
|
||||
error : `Load [${elementId}] not found!`
|
||||
})
|
||||
}
|
||||
}catch(error){
|
||||
console.error( error );
|
||||
return res.status( 500 ).send({ error });
|
||||
|
||||
@@ -41,7 +41,7 @@ const schema = new Schema({
|
||||
active_load: { type: Schema.Types.ObjectId, ref: 'loads' },
|
||||
load_shipper: { type: Schema.Types.ObjectId, ref: 'companies' },
|
||||
|
||||
available_in: [{ type: String }],
|
||||
available_in: { type: String },
|
||||
|
||||
destino: { type: String },
|
||||
driver: { type: Schema.Types.ObjectId, ref: 'users' },
|
||||
|
||||
Reference in New Issue
Block a user