How to retrieve more than 1000 rows from Parse.com?

前端 未结 10 1046
独厮守ぢ
独厮守ぢ 2020-11-29 19:54

I have been using Parse to retrieve a data for a list view. Unfortunately they limit requests to 100 by default to a 1000 max. I have well over that 1000 max in my class. I

10条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 20:42

    YAS (Yet Another Solution!) Using async() and await() in javascript.

    async parseFetchAll(collected = []) {
      let query = new Parse.Query(GameScore);
      const limit = 1000;
    
      query.limit(limit);
      query.skip(collected.length);
    
      const results = await query.find();
    
      if(results.length === limit) {
        return await parseFetchAll([ ...collected, ...results ]);
      } else {
        return collected.concat(results);
      }
    
    }
    

提交回复
热议问题