How to get more than 1000 results Parse [duplicate]

南楼画角 提交于 2019-11-29 11:58:17

I am using this code presently. This can fetch more than 1000 results. The values are sorted according to "objectId". You can sort according to "createdAt" by changing accordingly. Final results are stored in result array

      var result = [];
      var processCallback = function(res) {
                result = result.concat(res);
                if (res.length == 1000) {
                  process(res[res.length-1].id);
                  return;
                }   
                    //To print all the ids
                    for(var i=0;i<result.length;i++){
                        console.log(result[i].id);
                    }
                }

        var process = function(skip) {
            var query = new Parse.Query("ObjectName");

            if (skip) {
              query.greaterThan("objectId", skip);
            }
            query.limit(1000);
            query.ascending("objectId");
            query.find().then(function querySuccess(res) {
              processCallback(res);
            }, function queryFailed(error) {
                });
          }
      process(false);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!