fix(companies): populate /own endpoint
This commit is contained in:
@@ -101,7 +101,11 @@ async function getListByType( type , req ){
|
|||||||
async function getOwnCompany( req , res ) {
|
async function getOwnCompany( req , res ) {
|
||||||
try{
|
try{
|
||||||
const companyId = req.context.companyId;
|
const companyId = req.context.companyId;
|
||||||
const result = await companiesModel.findById( companyId );
|
const result = await companiesModel.findById( companyId )
|
||||||
|
.populate("categories" , "_id name")
|
||||||
|
.populate("company_city", "-_id name")
|
||||||
|
.populate("company_state", "-_id name")
|
||||||
|
.populate("truck_type", "-_id name");
|
||||||
return res.send( result );
|
return res.send( result );
|
||||||
}catch( error ){
|
}catch( error ){
|
||||||
console.error( error );
|
console.error( error );
|
||||||
@@ -114,7 +118,7 @@ async function patchOwnCompany( req , res ) {
|
|||||||
const companyId = req.context.companyId;
|
const companyId = req.context.companyId;
|
||||||
const data = req.body;
|
const data = req.body;
|
||||||
if( data.company_type ){ delete data.company_type; }
|
if( data.company_type ){ delete data.company_type; }
|
||||||
const company = await companiesModel.findByIdAndUpdate( companyId , data );
|
await companiesModel.findByIdAndUpdate( companyId , data );
|
||||||
const result = await companiesModel.findById( companyId );
|
const result = await companiesModel.findById( companyId );
|
||||||
return res.send( result );
|
return res.send( result );
|
||||||
}catch( error ){
|
}catch( error ){
|
||||||
|
|||||||
Reference in New Issue
Block a user