fix(loads): populate company and carrier fields
This commit is contained in:
14
lib/Misc.js
14
lib/Misc.js
@@ -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 };
|
||||
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user