fix(loads): populate company and carrier fields

This commit is contained in:
2023-10-06 20:28:12 -06:00
parent d019017600
commit e538e229f3
12 changed files with 51 additions and 32 deletions

View File

@@ -25,7 +25,7 @@ function getPagination( query ){
return limit;
}
async function queryPage( page, elements, model, filter=null, projection=null){
async function getPage( page, elements, model, filter=null, projection=null){
const skip = elements * page;
const total = await model.count( filter );
const list = await model.find( filter , projection, { skip : skip , limit : elements } );
@@ -37,4 +37,14 @@ async function queryPage( page, elements, model, filter=null, projection=null){
}
}
module.exports = { getPagination , queryPage };
async function queryPage(page, elements, model, filter=null, projection=null){
const skip = elements * page;
const total = await model.count( filter );
return {
query : model.find( filter , projection, { skip : skip , limit : elements } ),
total : total,
skip : skip
};
}
module.exports = { getPagination , getPage, queryPage };

View File

@@ -62,4 +62,4 @@ const schema = new Schema({
is_hidden: { type: Boolean, default: false },
});
module.exports = mongoose.model( "branches", schema );
module.exports = mongoose.model( "companies", schema );