Browse Source

adding pagination support

apprausch 5 years ago
parent
commit
0eabc42963
1 changed files with 6 additions and 1 deletions
  1. 6 1
      lib/index.js

+ 6 - 1
lib/index.js

@@ -583,11 +583,16 @@ router.get('/ShowAgg/:appId', function (req, res, next) {//Test Aggregation
 
 router.get('/downloadedapps/', function (req, res, next) {
   var filter = {};
+  var perPage = 10;
+  var page = 0;
 
   if(req.query.genre) {
     filter.genreId = { $regex: '.*' + req.query.genre + '.*' };
   }
-  models.app.find(filter)
+  if(req.query.page) {
+    page = req.query.page;
+  }
+  models.app.find(filter).sort('title').skip(perPage * page).limit(20)
     .then((apps) => apps.map(function (app) {
       app.url = "http://localhost:3000/crawler/downloadedapps/" + app.appId;
       return app;