diff --git a/lib/Misc.js b/lib/Misc.js index 3a488cb..1868336 100644 --- a/lib/Misc.js +++ b/lib/Misc.js @@ -11,6 +11,10 @@ function getPagination( query ){ } if( query.elements ){ limit.elements = parseInt( query.elements ) || 10; + /** Safe pagination limit */ + if( limit.elements > 1000 ){ + limit.elements = 1000; + } } return limit; } @@ -18,7 +22,7 @@ function getPagination( query ){ async function queryPage( page , elements , model ){ const skip = elements * page; const total = await model.count(); - const list = await model.find( {} , null, { skip : skip } ); + const list = await model.find( null , null, { skip : skip , limit : elements } ); return { total : total, limit : elements,