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











up vote
18
down vote

favorite
20












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 found a link on the web which shows a way to do it on iOS but how would you do it on Android? Web Link



I am currently adding all the data into a arraylist in a loop until all items are complete (100) then adding them to the list










share|improve this question




























    up vote
    18
    down vote

    favorite
    20












    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 found a link on the web which shows a way to do it on iOS but how would you do it on Android? Web Link



    I am currently adding all the data into a arraylist in a loop until all items are complete (100) then adding them to the list










    share|improve this question


























      up vote
      18
      down vote

      favorite
      20









      up vote
      18
      down vote

      favorite
      20






      20





      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 found a link on the web which shows a way to do it on iOS but how would you do it on Android? Web Link



      I am currently adding all the data into a arraylist in a loop until all items are complete (100) then adding them to the list










      share|improve this question















      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 found a link on the web which shows a way to do it on iOS but how would you do it on Android? Web Link



      I am currently adding all the data into a arraylist in a loop until all items are complete (100) then adding them to the list







      android listview parse.com






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 3 '16 at 7:48









      Termininja

      4,286122937




      4,286122937










      asked Jun 22 '13 at 3:12









      SquiresSquire

      1,73831738




      1,73831738
























          7 Answers
          7






          active

          oldest

          votes

















          up vote
          43
          down vote



          accepted










          I have figured out how to achieve my goal:





          Declare Global Variable



          private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


          Create Query



          final ParseQuery parseQuery = new ParseQuery("Objects");
          parseQuery.setLimit(1000);
          parseQuery.findInBackground(getAllObjects());


          Callback for Query



          int skip=0;
          FindCallback getAllObjects(){
          return new FindCallback(){
          public void done(List<ParseObject> objects, ParseException e) {
          if (e == null) {

          allObjects.addAll(objects);
          int limit =1000;
          if (objects.size() == limit){
          skip = skip + limit;
          ParseQuery query = new ParseQuery("Objects");
          query.setSkip(skip);
          query.setLimit(limit);
          query.findInBackground(getAllObjects());
          }
          //We have a full PokeDex
          else {
          //USE FULL DATA AS INTENDED
          }
          }
          };
          }





          share|improve this answer























          • What's the initial value of skip?
            – Faux Pas
            Sep 16 '14 at 18:42










          • The initial value should be 0, as you want to start at the first record, and keep skipping the limit until you have all the objects
            – SquiresSquire
            Sep 16 '14 at 21:38






          • 1




            i had to make 'skip' var to global for get this code working. but axcept for that code is greate
            – itzhar
            Apr 18 '15 at 21:28








          • 1




            Not sure why but it is not working for me. it's asking me to implement two: done(List objects, ParseException e) and done(Object o, Throwable throwable) methods and it is always calling the one with the one object
            – SHADOW.NET
            Nov 10 at 20:59


















          up vote
          14
          down vote













          Here is a JavaScript version without promises..



          These are the global variables (collections are not required, just a bad habit of mine)..



             ///create a collection of cool things and instantiate it (globally)
          var CoolCollection = Parse.Collection.extend({
          model: CoolThing
          }), coolCollection = new CoolCollection();


          This is the "looping" function that gets your results..



          //recursive call, initial loopCount is 0 (we haven't looped yet)
          function getAllRecords(loopCount){

          ///set your record limit
          var limit = 1000;

          ///create your eggstra-special query
          new Parse.Query(CoolThings)
          .limit(limit)
          .skip(limit * loopCount) //<-important
          .find({
          success: function (results) {
          if(results.length > 0){

          //we do stuff in here like "add items to a collection of cool things"
          for(var j=0; j < results.length; j++){
          coolCollection.add(results[j]);
          }

          loopCount++; //<--increment our loop because we are not done

          getAllRecords(loopCount); //<--recurse
          }
          else
          {
          //our query has run out of steam, this else{} will be called one time only
          coolCollection.each(function(coolThing){
          //do something awesome with each of your cool things
          });
          }
          },
          error: function (error) {
          //badness with the find
          }
          });
          }


          This is how you call it (or you could do it other ways):



          getAllRecords(0);





          share|improve this answer




























            up vote
            1
            down vote













            In C# I use this recursion:



            private static async Task GetAll(int count = 0, int limit = 1000)
            {
            if (count * limit != list.Count) return;
            var res = await ParseObject.GetQuery("Row").Limit(limit).Skip(list.Count).FindAsync();
            res.ToList().ForEach(x => list.Add(x));
            await GetAll(++count);
            }


            JS version:



            function getAll(list) {
            new Parse.Query(Row).limit(1000).skip(list.length).find().then(function (result) {
            list = list.concat(result);
            if (result.length != 1000) {
            //do here something with the list...
            return;
            }

            getAll(list);
            });
            }


            Usage: GetAll() in C#, and getAll() in JS.



            I store all rows from the class Rowin the list. In each request I get 1000 rows and skip the current size of the list. Recursion stops when the current number of exported rows is different from the expected.






            share|improve this answer






























              up vote
              1
              down vote













              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);
              }

              }





              share|improve this answer




























                up vote
                1
                down vote













                A Swift 3 Example:



                var users    = [String] ()
                var payments = [String] ()
                ///set your record limit
                let limit = 29
                //recursive call, initial loopCount is 0 (we haven't looped yet)
                func loadAllPaymentDetails(_ loopCount: Int){
                ///create your NEW eggstra-special query
                let paymentsQuery = Payments.query()
                paymentsQuery?.limit = limit
                paymentsQuery?.skip = limit*loopCount
                paymentsQuery?.findObjectsInBackground(block: { (objects, error) in
                if let objects = objects {
                //print(#file.getClass()," ",#function," loopcount: ",loopCount," #ReturnedObjects: ", objects.count)
                if objects.count > 0 {
                //print(#function, " no. of objects :", objects.count)
                for paymentsObject in objects {
                let user = paymentsObject[Utils.name] as! String
                let amount = paymentsObject[Utils.amount] as! String
                self.users.append(user)
                self.payments.append(amount)
                }
                //recurse our loop with increment because we are not done
                self.loadAllPaymentDetails(loopCount + 1); //<--recurse
                }else {
                //our query has run out of steam, this else{} will be called one time only
                //if the Table had been initially empty, lets inform the user:
                if self.users.count == 1 {
                Utils.createAlert(self, title: "No Payment has been made yet", message: "Please Encourage Users to make some Payments", buttonTitle: "Ok")
                }else {
                self.tableView.reloadData()
                }
                }
                }else if error != nil {
                print(error!)
                }else {
                print("Unknown Error")
                }
                })
                }


                adapted from @deLux_247's example above.






                share|improve this answer




























                  up vote
                  1
                  down vote













                  JAVA



                  So after 5 years, 4 months the above answer of @SquiresSquire needed some changes to make it work for me, and I would like to share it with you



                  private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


                  .



                   ParseQuery<ParseObject> parseQuery = new ParseQuery<ParseObject>("CLASSNAME");
                  parseQuery.setLimit(1000);
                  parseQuery.findInBackground(getAllObjects());


                  .



                  FindCallback <ParseObject> getAllObjects() {
                  return new FindCallback <ParseObject>() {
                  @Override
                  public void done(List<ParseObject> objects, ParseException e) {
                  if (e == null) {
                  allObjects.addAll(objects);
                  int limit = 1000;
                  if (objects.size() == limit) {
                  skip = skip + limit;
                  ParseQuery query = new ParseQuery("CLASSNAME");
                  query.setSkip(skip);
                  query.setLimit(limit);
                  query.findInBackground(getAllObjects());
                  }
                  //We have a full PokeDex
                  else {
                  //USE FULL DATA AS INTENDED
                  }
                  }
                  }

                  };





                  share|improve this answer






























                    up vote
                    0
                    down vote













                    You could achieve this using CloudCode... Make a custom function you can call that will enumerate the entire collection and build a response from that but a wiser choice would be to paginate your requests, and fetch the records 1000 (or even less) at a time, adding them into your list dynamically as required.






                    share|improve this answer





















                    • an example would have been helfpful.
                      – nyxee
                      Jul 31 '17 at 21:50











                    Your Answer






                    StackExchange.ifUsing("editor", function () {
                    StackExchange.using("externalEditor", function () {
                    StackExchange.using("snippets", function () {
                    StackExchange.snippets.init();
                    });
                    });
                    }, "code-snippets");

                    StackExchange.ready(function() {
                    var channelOptions = {
                    tags: "".split(" "),
                    id: "1"
                    };
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function() {
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled) {
                    StackExchange.using("snippets", function() {
                    createEditor();
                    });
                    }
                    else {
                    createEditor();
                    }
                    });

                    function createEditor() {
                    StackExchange.prepareEditor({
                    heartbeatType: 'answer',
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader: {
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    },
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    });


                    }
                    });














                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17246991%2fhow-to-retrieve-more-than-1000-rows-from-parse-com%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown

























                    7 Answers
                    7






                    active

                    oldest

                    votes








                    7 Answers
                    7






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes








                    up vote
                    43
                    down vote



                    accepted










                    I have figured out how to achieve my goal:





                    Declare Global Variable



                    private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


                    Create Query



                    final ParseQuery parseQuery = new ParseQuery("Objects");
                    parseQuery.setLimit(1000);
                    parseQuery.findInBackground(getAllObjects());


                    Callback for Query



                    int skip=0;
                    FindCallback getAllObjects(){
                    return new FindCallback(){
                    public void done(List<ParseObject> objects, ParseException e) {
                    if (e == null) {

                    allObjects.addAll(objects);
                    int limit =1000;
                    if (objects.size() == limit){
                    skip = skip + limit;
                    ParseQuery query = new ParseQuery("Objects");
                    query.setSkip(skip);
                    query.setLimit(limit);
                    query.findInBackground(getAllObjects());
                    }
                    //We have a full PokeDex
                    else {
                    //USE FULL DATA AS INTENDED
                    }
                    }
                    };
                    }





                    share|improve this answer























                    • What's the initial value of skip?
                      – Faux Pas
                      Sep 16 '14 at 18:42










                    • The initial value should be 0, as you want to start at the first record, and keep skipping the limit until you have all the objects
                      – SquiresSquire
                      Sep 16 '14 at 21:38






                    • 1




                      i had to make 'skip' var to global for get this code working. but axcept for that code is greate
                      – itzhar
                      Apr 18 '15 at 21:28








                    • 1




                      Not sure why but it is not working for me. it's asking me to implement two: done(List objects, ParseException e) and done(Object o, Throwable throwable) methods and it is always calling the one with the one object
                      – SHADOW.NET
                      Nov 10 at 20:59















                    up vote
                    43
                    down vote



                    accepted










                    I have figured out how to achieve my goal:





                    Declare Global Variable



                    private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


                    Create Query



                    final ParseQuery parseQuery = new ParseQuery("Objects");
                    parseQuery.setLimit(1000);
                    parseQuery.findInBackground(getAllObjects());


                    Callback for Query



                    int skip=0;
                    FindCallback getAllObjects(){
                    return new FindCallback(){
                    public void done(List<ParseObject> objects, ParseException e) {
                    if (e == null) {

                    allObjects.addAll(objects);
                    int limit =1000;
                    if (objects.size() == limit){
                    skip = skip + limit;
                    ParseQuery query = new ParseQuery("Objects");
                    query.setSkip(skip);
                    query.setLimit(limit);
                    query.findInBackground(getAllObjects());
                    }
                    //We have a full PokeDex
                    else {
                    //USE FULL DATA AS INTENDED
                    }
                    }
                    };
                    }





                    share|improve this answer























                    • What's the initial value of skip?
                      – Faux Pas
                      Sep 16 '14 at 18:42










                    • The initial value should be 0, as you want to start at the first record, and keep skipping the limit until you have all the objects
                      – SquiresSquire
                      Sep 16 '14 at 21:38






                    • 1




                      i had to make 'skip' var to global for get this code working. but axcept for that code is greate
                      – itzhar
                      Apr 18 '15 at 21:28








                    • 1




                      Not sure why but it is not working for me. it's asking me to implement two: done(List objects, ParseException e) and done(Object o, Throwable throwable) methods and it is always calling the one with the one object
                      – SHADOW.NET
                      Nov 10 at 20:59













                    up vote
                    43
                    down vote



                    accepted







                    up vote
                    43
                    down vote



                    accepted






                    I have figured out how to achieve my goal:





                    Declare Global Variable



                    private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


                    Create Query



                    final ParseQuery parseQuery = new ParseQuery("Objects");
                    parseQuery.setLimit(1000);
                    parseQuery.findInBackground(getAllObjects());


                    Callback for Query



                    int skip=0;
                    FindCallback getAllObjects(){
                    return new FindCallback(){
                    public void done(List<ParseObject> objects, ParseException e) {
                    if (e == null) {

                    allObjects.addAll(objects);
                    int limit =1000;
                    if (objects.size() == limit){
                    skip = skip + limit;
                    ParseQuery query = new ParseQuery("Objects");
                    query.setSkip(skip);
                    query.setLimit(limit);
                    query.findInBackground(getAllObjects());
                    }
                    //We have a full PokeDex
                    else {
                    //USE FULL DATA AS INTENDED
                    }
                    }
                    };
                    }





                    share|improve this answer














                    I have figured out how to achieve my goal:





                    Declare Global Variable



                    private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


                    Create Query



                    final ParseQuery parseQuery = new ParseQuery("Objects");
                    parseQuery.setLimit(1000);
                    parseQuery.findInBackground(getAllObjects());


                    Callback for Query



                    int skip=0;
                    FindCallback getAllObjects(){
                    return new FindCallback(){
                    public void done(List<ParseObject> objects, ParseException e) {
                    if (e == null) {

                    allObjects.addAll(objects);
                    int limit =1000;
                    if (objects.size() == limit){
                    skip = skip + limit;
                    ParseQuery query = new ParseQuery("Objects");
                    query.setSkip(skip);
                    query.setLimit(limit);
                    query.findInBackground(getAllObjects());
                    }
                    //We have a full PokeDex
                    else {
                    //USE FULL DATA AS INTENDED
                    }
                    }
                    };
                    }






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 15 '15 at 16:21









                    thumbmunkeys

                    17.4k852101




                    17.4k852101










                    answered Sep 9 '13 at 10:39









                    SquiresSquire

                    1,73831738




                    1,73831738












                    • What's the initial value of skip?
                      – Faux Pas
                      Sep 16 '14 at 18:42










                    • The initial value should be 0, as you want to start at the first record, and keep skipping the limit until you have all the objects
                      – SquiresSquire
                      Sep 16 '14 at 21:38






                    • 1




                      i had to make 'skip' var to global for get this code working. but axcept for that code is greate
                      – itzhar
                      Apr 18 '15 at 21:28








                    • 1




                      Not sure why but it is not working for me. it's asking me to implement two: done(List objects, ParseException e) and done(Object o, Throwable throwable) methods and it is always calling the one with the one object
                      – SHADOW.NET
                      Nov 10 at 20:59


















                    • What's the initial value of skip?
                      – Faux Pas
                      Sep 16 '14 at 18:42










                    • The initial value should be 0, as you want to start at the first record, and keep skipping the limit until you have all the objects
                      – SquiresSquire
                      Sep 16 '14 at 21:38






                    • 1




                      i had to make 'skip' var to global for get this code working. but axcept for that code is greate
                      – itzhar
                      Apr 18 '15 at 21:28








                    • 1




                      Not sure why but it is not working for me. it's asking me to implement two: done(List objects, ParseException e) and done(Object o, Throwable throwable) methods and it is always calling the one with the one object
                      – SHADOW.NET
                      Nov 10 at 20:59
















                    What's the initial value of skip?
                    – Faux Pas
                    Sep 16 '14 at 18:42




                    What's the initial value of skip?
                    – Faux Pas
                    Sep 16 '14 at 18:42












                    The initial value should be 0, as you want to start at the first record, and keep skipping the limit until you have all the objects
                    – SquiresSquire
                    Sep 16 '14 at 21:38




                    The initial value should be 0, as you want to start at the first record, and keep skipping the limit until you have all the objects
                    – SquiresSquire
                    Sep 16 '14 at 21:38




                    1




                    1




                    i had to make 'skip' var to global for get this code working. but axcept for that code is greate
                    – itzhar
                    Apr 18 '15 at 21:28






                    i had to make 'skip' var to global for get this code working. but axcept for that code is greate
                    – itzhar
                    Apr 18 '15 at 21:28






                    1




                    1




                    Not sure why but it is not working for me. it's asking me to implement two: done(List objects, ParseException e) and done(Object o, Throwable throwable) methods and it is always calling the one with the one object
                    – SHADOW.NET
                    Nov 10 at 20:59




                    Not sure why but it is not working for me. it's asking me to implement two: done(List objects, ParseException e) and done(Object o, Throwable throwable) methods and it is always calling the one with the one object
                    – SHADOW.NET
                    Nov 10 at 20:59












                    up vote
                    14
                    down vote













                    Here is a JavaScript version without promises..



                    These are the global variables (collections are not required, just a bad habit of mine)..



                       ///create a collection of cool things and instantiate it (globally)
                    var CoolCollection = Parse.Collection.extend({
                    model: CoolThing
                    }), coolCollection = new CoolCollection();


                    This is the "looping" function that gets your results..



                    //recursive call, initial loopCount is 0 (we haven't looped yet)
                    function getAllRecords(loopCount){

                    ///set your record limit
                    var limit = 1000;

                    ///create your eggstra-special query
                    new Parse.Query(CoolThings)
                    .limit(limit)
                    .skip(limit * loopCount) //<-important
                    .find({
                    success: function (results) {
                    if(results.length > 0){

                    //we do stuff in here like "add items to a collection of cool things"
                    for(var j=0; j < results.length; j++){
                    coolCollection.add(results[j]);
                    }

                    loopCount++; //<--increment our loop because we are not done

                    getAllRecords(loopCount); //<--recurse
                    }
                    else
                    {
                    //our query has run out of steam, this else{} will be called one time only
                    coolCollection.each(function(coolThing){
                    //do something awesome with each of your cool things
                    });
                    }
                    },
                    error: function (error) {
                    //badness with the find
                    }
                    });
                    }


                    This is how you call it (or you could do it other ways):



                    getAllRecords(0);





                    share|improve this answer

























                      up vote
                      14
                      down vote













                      Here is a JavaScript version without promises..



                      These are the global variables (collections are not required, just a bad habit of mine)..



                         ///create a collection of cool things and instantiate it (globally)
                      var CoolCollection = Parse.Collection.extend({
                      model: CoolThing
                      }), coolCollection = new CoolCollection();


                      This is the "looping" function that gets your results..



                      //recursive call, initial loopCount is 0 (we haven't looped yet)
                      function getAllRecords(loopCount){

                      ///set your record limit
                      var limit = 1000;

                      ///create your eggstra-special query
                      new Parse.Query(CoolThings)
                      .limit(limit)
                      .skip(limit * loopCount) //<-important
                      .find({
                      success: function (results) {
                      if(results.length > 0){

                      //we do stuff in here like "add items to a collection of cool things"
                      for(var j=0; j < results.length; j++){
                      coolCollection.add(results[j]);
                      }

                      loopCount++; //<--increment our loop because we are not done

                      getAllRecords(loopCount); //<--recurse
                      }
                      else
                      {
                      //our query has run out of steam, this else{} will be called one time only
                      coolCollection.each(function(coolThing){
                      //do something awesome with each of your cool things
                      });
                      }
                      },
                      error: function (error) {
                      //badness with the find
                      }
                      });
                      }


                      This is how you call it (or you could do it other ways):



                      getAllRecords(0);





                      share|improve this answer























                        up vote
                        14
                        down vote










                        up vote
                        14
                        down vote









                        Here is a JavaScript version without promises..



                        These are the global variables (collections are not required, just a bad habit of mine)..



                           ///create a collection of cool things and instantiate it (globally)
                        var CoolCollection = Parse.Collection.extend({
                        model: CoolThing
                        }), coolCollection = new CoolCollection();


                        This is the "looping" function that gets your results..



                        //recursive call, initial loopCount is 0 (we haven't looped yet)
                        function getAllRecords(loopCount){

                        ///set your record limit
                        var limit = 1000;

                        ///create your eggstra-special query
                        new Parse.Query(CoolThings)
                        .limit(limit)
                        .skip(limit * loopCount) //<-important
                        .find({
                        success: function (results) {
                        if(results.length > 0){

                        //we do stuff in here like "add items to a collection of cool things"
                        for(var j=0; j < results.length; j++){
                        coolCollection.add(results[j]);
                        }

                        loopCount++; //<--increment our loop because we are not done

                        getAllRecords(loopCount); //<--recurse
                        }
                        else
                        {
                        //our query has run out of steam, this else{} will be called one time only
                        coolCollection.each(function(coolThing){
                        //do something awesome with each of your cool things
                        });
                        }
                        },
                        error: function (error) {
                        //badness with the find
                        }
                        });
                        }


                        This is how you call it (or you could do it other ways):



                        getAllRecords(0);





                        share|improve this answer












                        Here is a JavaScript version without promises..



                        These are the global variables (collections are not required, just a bad habit of mine)..



                           ///create a collection of cool things and instantiate it (globally)
                        var CoolCollection = Parse.Collection.extend({
                        model: CoolThing
                        }), coolCollection = new CoolCollection();


                        This is the "looping" function that gets your results..



                        //recursive call, initial loopCount is 0 (we haven't looped yet)
                        function getAllRecords(loopCount){

                        ///set your record limit
                        var limit = 1000;

                        ///create your eggstra-special query
                        new Parse.Query(CoolThings)
                        .limit(limit)
                        .skip(limit * loopCount) //<-important
                        .find({
                        success: function (results) {
                        if(results.length > 0){

                        //we do stuff in here like "add items to a collection of cool things"
                        for(var j=0; j < results.length; j++){
                        coolCollection.add(results[j]);
                        }

                        loopCount++; //<--increment our loop because we are not done

                        getAllRecords(loopCount); //<--recurse
                        }
                        else
                        {
                        //our query has run out of steam, this else{} will be called one time only
                        coolCollection.each(function(coolThing){
                        //do something awesome with each of your cool things
                        });
                        }
                        },
                        error: function (error) {
                        //badness with the find
                        }
                        });
                        }


                        This is how you call it (or you could do it other ways):



                        getAllRecords(0);






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Sep 11 '14 at 0:46









                        deLux_247

                        16115




                        16115






















                            up vote
                            1
                            down vote













                            In C# I use this recursion:



                            private static async Task GetAll(int count = 0, int limit = 1000)
                            {
                            if (count * limit != list.Count) return;
                            var res = await ParseObject.GetQuery("Row").Limit(limit).Skip(list.Count).FindAsync();
                            res.ToList().ForEach(x => list.Add(x));
                            await GetAll(++count);
                            }


                            JS version:



                            function getAll(list) {
                            new Parse.Query(Row).limit(1000).skip(list.length).find().then(function (result) {
                            list = list.concat(result);
                            if (result.length != 1000) {
                            //do here something with the list...
                            return;
                            }

                            getAll(list);
                            });
                            }


                            Usage: GetAll() in C#, and getAll() in JS.



                            I store all rows from the class Rowin the list. In each request I get 1000 rows and skip the current size of the list. Recursion stops when the current number of exported rows is different from the expected.






                            share|improve this answer



























                              up vote
                              1
                              down vote













                              In C# I use this recursion:



                              private static async Task GetAll(int count = 0, int limit = 1000)
                              {
                              if (count * limit != list.Count) return;
                              var res = await ParseObject.GetQuery("Row").Limit(limit).Skip(list.Count).FindAsync();
                              res.ToList().ForEach(x => list.Add(x));
                              await GetAll(++count);
                              }


                              JS version:



                              function getAll(list) {
                              new Parse.Query(Row).limit(1000).skip(list.length).find().then(function (result) {
                              list = list.concat(result);
                              if (result.length != 1000) {
                              //do here something with the list...
                              return;
                              }

                              getAll(list);
                              });
                              }


                              Usage: GetAll() in C#, and getAll() in JS.



                              I store all rows from the class Rowin the list. In each request I get 1000 rows and skip the current size of the list. Recursion stops when the current number of exported rows is different from the expected.






                              share|improve this answer

























                                up vote
                                1
                                down vote










                                up vote
                                1
                                down vote









                                In C# I use this recursion:



                                private static async Task GetAll(int count = 0, int limit = 1000)
                                {
                                if (count * limit != list.Count) return;
                                var res = await ParseObject.GetQuery("Row").Limit(limit).Skip(list.Count).FindAsync();
                                res.ToList().ForEach(x => list.Add(x));
                                await GetAll(++count);
                                }


                                JS version:



                                function getAll(list) {
                                new Parse.Query(Row).limit(1000).skip(list.length).find().then(function (result) {
                                list = list.concat(result);
                                if (result.length != 1000) {
                                //do here something with the list...
                                return;
                                }

                                getAll(list);
                                });
                                }


                                Usage: GetAll() in C#, and getAll() in JS.



                                I store all rows from the class Rowin the list. In each request I get 1000 rows and skip the current size of the list. Recursion stops when the current number of exported rows is different from the expected.






                                share|improve this answer














                                In C# I use this recursion:



                                private static async Task GetAll(int count = 0, int limit = 1000)
                                {
                                if (count * limit != list.Count) return;
                                var res = await ParseObject.GetQuery("Row").Limit(limit).Skip(list.Count).FindAsync();
                                res.ToList().ForEach(x => list.Add(x));
                                await GetAll(++count);
                                }


                                JS version:



                                function getAll(list) {
                                new Parse.Query(Row).limit(1000).skip(list.length).find().then(function (result) {
                                list = list.concat(result);
                                if (result.length != 1000) {
                                //do here something with the list...
                                return;
                                }

                                getAll(list);
                                });
                                }


                                Usage: GetAll() in C#, and getAll() in JS.



                                I store all rows from the class Rowin the list. In each request I get 1000 rows and skip the current size of the list. Recursion stops when the current number of exported rows is different from the expected.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Nov 3 '16 at 7:50

























                                answered Jan 28 '16 at 11:59









                                Termininja

                                4,286122937




                                4,286122937






















                                    up vote
                                    1
                                    down vote













                                    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);
                                    }

                                    }





                                    share|improve this answer

























                                      up vote
                                      1
                                      down vote













                                      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);
                                      }

                                      }





                                      share|improve this answer























                                        up vote
                                        1
                                        down vote










                                        up vote
                                        1
                                        down vote









                                        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);
                                        }

                                        }





                                        share|improve this answer












                                        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);
                                        }

                                        }






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Jul 5 '17 at 23:30









                                        Dygerati

                                        456313




                                        456313






















                                            up vote
                                            1
                                            down vote













                                            A Swift 3 Example:



                                            var users    = [String] ()
                                            var payments = [String] ()
                                            ///set your record limit
                                            let limit = 29
                                            //recursive call, initial loopCount is 0 (we haven't looped yet)
                                            func loadAllPaymentDetails(_ loopCount: Int){
                                            ///create your NEW eggstra-special query
                                            let paymentsQuery = Payments.query()
                                            paymentsQuery?.limit = limit
                                            paymentsQuery?.skip = limit*loopCount
                                            paymentsQuery?.findObjectsInBackground(block: { (objects, error) in
                                            if let objects = objects {
                                            //print(#file.getClass()," ",#function," loopcount: ",loopCount," #ReturnedObjects: ", objects.count)
                                            if objects.count > 0 {
                                            //print(#function, " no. of objects :", objects.count)
                                            for paymentsObject in objects {
                                            let user = paymentsObject[Utils.name] as! String
                                            let amount = paymentsObject[Utils.amount] as! String
                                            self.users.append(user)
                                            self.payments.append(amount)
                                            }
                                            //recurse our loop with increment because we are not done
                                            self.loadAllPaymentDetails(loopCount + 1); //<--recurse
                                            }else {
                                            //our query has run out of steam, this else{} will be called one time only
                                            //if the Table had been initially empty, lets inform the user:
                                            if self.users.count == 1 {
                                            Utils.createAlert(self, title: "No Payment has been made yet", message: "Please Encourage Users to make some Payments", buttonTitle: "Ok")
                                            }else {
                                            self.tableView.reloadData()
                                            }
                                            }
                                            }else if error != nil {
                                            print(error!)
                                            }else {
                                            print("Unknown Error")
                                            }
                                            })
                                            }


                                            adapted from @deLux_247's example above.






                                            share|improve this answer

























                                              up vote
                                              1
                                              down vote













                                              A Swift 3 Example:



                                              var users    = [String] ()
                                              var payments = [String] ()
                                              ///set your record limit
                                              let limit = 29
                                              //recursive call, initial loopCount is 0 (we haven't looped yet)
                                              func loadAllPaymentDetails(_ loopCount: Int){
                                              ///create your NEW eggstra-special query
                                              let paymentsQuery = Payments.query()
                                              paymentsQuery?.limit = limit
                                              paymentsQuery?.skip = limit*loopCount
                                              paymentsQuery?.findObjectsInBackground(block: { (objects, error) in
                                              if let objects = objects {
                                              //print(#file.getClass()," ",#function," loopcount: ",loopCount," #ReturnedObjects: ", objects.count)
                                              if objects.count > 0 {
                                              //print(#function, " no. of objects :", objects.count)
                                              for paymentsObject in objects {
                                              let user = paymentsObject[Utils.name] as! String
                                              let amount = paymentsObject[Utils.amount] as! String
                                              self.users.append(user)
                                              self.payments.append(amount)
                                              }
                                              //recurse our loop with increment because we are not done
                                              self.loadAllPaymentDetails(loopCount + 1); //<--recurse
                                              }else {
                                              //our query has run out of steam, this else{} will be called one time only
                                              //if the Table had been initially empty, lets inform the user:
                                              if self.users.count == 1 {
                                              Utils.createAlert(self, title: "No Payment has been made yet", message: "Please Encourage Users to make some Payments", buttonTitle: "Ok")
                                              }else {
                                              self.tableView.reloadData()
                                              }
                                              }
                                              }else if error != nil {
                                              print(error!)
                                              }else {
                                              print("Unknown Error")
                                              }
                                              })
                                              }


                                              adapted from @deLux_247's example above.






                                              share|improve this answer























                                                up vote
                                                1
                                                down vote










                                                up vote
                                                1
                                                down vote









                                                A Swift 3 Example:



                                                var users    = [String] ()
                                                var payments = [String] ()
                                                ///set your record limit
                                                let limit = 29
                                                //recursive call, initial loopCount is 0 (we haven't looped yet)
                                                func loadAllPaymentDetails(_ loopCount: Int){
                                                ///create your NEW eggstra-special query
                                                let paymentsQuery = Payments.query()
                                                paymentsQuery?.limit = limit
                                                paymentsQuery?.skip = limit*loopCount
                                                paymentsQuery?.findObjectsInBackground(block: { (objects, error) in
                                                if let objects = objects {
                                                //print(#file.getClass()," ",#function," loopcount: ",loopCount," #ReturnedObjects: ", objects.count)
                                                if objects.count > 0 {
                                                //print(#function, " no. of objects :", objects.count)
                                                for paymentsObject in objects {
                                                let user = paymentsObject[Utils.name] as! String
                                                let amount = paymentsObject[Utils.amount] as! String
                                                self.users.append(user)
                                                self.payments.append(amount)
                                                }
                                                //recurse our loop with increment because we are not done
                                                self.loadAllPaymentDetails(loopCount + 1); //<--recurse
                                                }else {
                                                //our query has run out of steam, this else{} will be called one time only
                                                //if the Table had been initially empty, lets inform the user:
                                                if self.users.count == 1 {
                                                Utils.createAlert(self, title: "No Payment has been made yet", message: "Please Encourage Users to make some Payments", buttonTitle: "Ok")
                                                }else {
                                                self.tableView.reloadData()
                                                }
                                                }
                                                }else if error != nil {
                                                print(error!)
                                                }else {
                                                print("Unknown Error")
                                                }
                                                })
                                                }


                                                adapted from @deLux_247's example above.






                                                share|improve this answer












                                                A Swift 3 Example:



                                                var users    = [String] ()
                                                var payments = [String] ()
                                                ///set your record limit
                                                let limit = 29
                                                //recursive call, initial loopCount is 0 (we haven't looped yet)
                                                func loadAllPaymentDetails(_ loopCount: Int){
                                                ///create your NEW eggstra-special query
                                                let paymentsQuery = Payments.query()
                                                paymentsQuery?.limit = limit
                                                paymentsQuery?.skip = limit*loopCount
                                                paymentsQuery?.findObjectsInBackground(block: { (objects, error) in
                                                if let objects = objects {
                                                //print(#file.getClass()," ",#function," loopcount: ",loopCount," #ReturnedObjects: ", objects.count)
                                                if objects.count > 0 {
                                                //print(#function, " no. of objects :", objects.count)
                                                for paymentsObject in objects {
                                                let user = paymentsObject[Utils.name] as! String
                                                let amount = paymentsObject[Utils.amount] as! String
                                                self.users.append(user)
                                                self.payments.append(amount)
                                                }
                                                //recurse our loop with increment because we are not done
                                                self.loadAllPaymentDetails(loopCount + 1); //<--recurse
                                                }else {
                                                //our query has run out of steam, this else{} will be called one time only
                                                //if the Table had been initially empty, lets inform the user:
                                                if self.users.count == 1 {
                                                Utils.createAlert(self, title: "No Payment has been made yet", message: "Please Encourage Users to make some Payments", buttonTitle: "Ok")
                                                }else {
                                                self.tableView.reloadData()
                                                }
                                                }
                                                }else if error != nil {
                                                print(error!)
                                                }else {
                                                print("Unknown Error")
                                                }
                                                })
                                                }


                                                adapted from @deLux_247's example above.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Jul 31 '17 at 21:48









                                                nyxee

                                                1,3081317




                                                1,3081317






















                                                    up vote
                                                    1
                                                    down vote













                                                    JAVA



                                                    So after 5 years, 4 months the above answer of @SquiresSquire needed some changes to make it work for me, and I would like to share it with you



                                                    private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


                                                    .



                                                     ParseQuery<ParseObject> parseQuery = new ParseQuery<ParseObject>("CLASSNAME");
                                                    parseQuery.setLimit(1000);
                                                    parseQuery.findInBackground(getAllObjects());


                                                    .



                                                    FindCallback <ParseObject> getAllObjects() {
                                                    return new FindCallback <ParseObject>() {
                                                    @Override
                                                    public void done(List<ParseObject> objects, ParseException e) {
                                                    if (e == null) {
                                                    allObjects.addAll(objects);
                                                    int limit = 1000;
                                                    if (objects.size() == limit) {
                                                    skip = skip + limit;
                                                    ParseQuery query = new ParseQuery("CLASSNAME");
                                                    query.setSkip(skip);
                                                    query.setLimit(limit);
                                                    query.findInBackground(getAllObjects());
                                                    }
                                                    //We have a full PokeDex
                                                    else {
                                                    //USE FULL DATA AS INTENDED
                                                    }
                                                    }
                                                    }

                                                    };





                                                    share|improve this answer



























                                                      up vote
                                                      1
                                                      down vote













                                                      JAVA



                                                      So after 5 years, 4 months the above answer of @SquiresSquire needed some changes to make it work for me, and I would like to share it with you



                                                      private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


                                                      .



                                                       ParseQuery<ParseObject> parseQuery = new ParseQuery<ParseObject>("CLASSNAME");
                                                      parseQuery.setLimit(1000);
                                                      parseQuery.findInBackground(getAllObjects());


                                                      .



                                                      FindCallback <ParseObject> getAllObjects() {
                                                      return new FindCallback <ParseObject>() {
                                                      @Override
                                                      public void done(List<ParseObject> objects, ParseException e) {
                                                      if (e == null) {
                                                      allObjects.addAll(objects);
                                                      int limit = 1000;
                                                      if (objects.size() == limit) {
                                                      skip = skip + limit;
                                                      ParseQuery query = new ParseQuery("CLASSNAME");
                                                      query.setSkip(skip);
                                                      query.setLimit(limit);
                                                      query.findInBackground(getAllObjects());
                                                      }
                                                      //We have a full PokeDex
                                                      else {
                                                      //USE FULL DATA AS INTENDED
                                                      }
                                                      }
                                                      }

                                                      };





                                                      share|improve this answer

























                                                        up vote
                                                        1
                                                        down vote










                                                        up vote
                                                        1
                                                        down vote









                                                        JAVA



                                                        So after 5 years, 4 months the above answer of @SquiresSquire needed some changes to make it work for me, and I would like to share it with you



                                                        private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


                                                        .



                                                         ParseQuery<ParseObject> parseQuery = new ParseQuery<ParseObject>("CLASSNAME");
                                                        parseQuery.setLimit(1000);
                                                        parseQuery.findInBackground(getAllObjects());


                                                        .



                                                        FindCallback <ParseObject> getAllObjects() {
                                                        return new FindCallback <ParseObject>() {
                                                        @Override
                                                        public void done(List<ParseObject> objects, ParseException e) {
                                                        if (e == null) {
                                                        allObjects.addAll(objects);
                                                        int limit = 1000;
                                                        if (objects.size() == limit) {
                                                        skip = skip + limit;
                                                        ParseQuery query = new ParseQuery("CLASSNAME");
                                                        query.setSkip(skip);
                                                        query.setLimit(limit);
                                                        query.findInBackground(getAllObjects());
                                                        }
                                                        //We have a full PokeDex
                                                        else {
                                                        //USE FULL DATA AS INTENDED
                                                        }
                                                        }
                                                        }

                                                        };





                                                        share|improve this answer














                                                        JAVA



                                                        So after 5 years, 4 months the above answer of @SquiresSquire needed some changes to make it work for me, and I would like to share it with you



                                                        private static List<ParseObject>allObjects = new ArrayList<ParseObject>();


                                                        .



                                                         ParseQuery<ParseObject> parseQuery = new ParseQuery<ParseObject>("CLASSNAME");
                                                        parseQuery.setLimit(1000);
                                                        parseQuery.findInBackground(getAllObjects());


                                                        .



                                                        FindCallback <ParseObject> getAllObjects() {
                                                        return new FindCallback <ParseObject>() {
                                                        @Override
                                                        public void done(List<ParseObject> objects, ParseException e) {
                                                        if (e == null) {
                                                        allObjects.addAll(objects);
                                                        int limit = 1000;
                                                        if (objects.size() == limit) {
                                                        skip = skip + limit;
                                                        ParseQuery query = new ParseQuery("CLASSNAME");
                                                        query.setSkip(skip);
                                                        query.setLimit(limit);
                                                        query.findInBackground(getAllObjects());
                                                        }
                                                        //We have a full PokeDex
                                                        else {
                                                        //USE FULL DATA AS INTENDED
                                                        }
                                                        }
                                                        }

                                                        };






                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited Nov 11 at 14:05

























                                                        answered Nov 10 at 21:34









                                                        SHADOW.NET

                                                        1121110




                                                        1121110






















                                                            up vote
                                                            0
                                                            down vote













                                                            You could achieve this using CloudCode... Make a custom function you can call that will enumerate the entire collection and build a response from that but a wiser choice would be to paginate your requests, and fetch the records 1000 (or even less) at a time, adding them into your list dynamically as required.






                                                            share|improve this answer





















                                                            • an example would have been helfpful.
                                                              – nyxee
                                                              Jul 31 '17 at 21:50















                                                            up vote
                                                            0
                                                            down vote













                                                            You could achieve this using CloudCode... Make a custom function you can call that will enumerate the entire collection and build a response from that but a wiser choice would be to paginate your requests, and fetch the records 1000 (or even less) at a time, adding them into your list dynamically as required.






                                                            share|improve this answer





















                                                            • an example would have been helfpful.
                                                              – nyxee
                                                              Jul 31 '17 at 21:50













                                                            up vote
                                                            0
                                                            down vote










                                                            up vote
                                                            0
                                                            down vote









                                                            You could achieve this using CloudCode... Make a custom function you can call that will enumerate the entire collection and build a response from that but a wiser choice would be to paginate your requests, and fetch the records 1000 (or even less) at a time, adding them into your list dynamically as required.






                                                            share|improve this answer












                                                            You could achieve this using CloudCode... Make a custom function you can call that will enumerate the entire collection and build a response from that but a wiser choice would be to paginate your requests, and fetch the records 1000 (or even less) at a time, adding them into your list dynamically as required.







                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered Jun 24 '13 at 7:06









                                                            Pete Martin

                                                            710615




                                                            710615












                                                            • an example would have been helfpful.
                                                              – nyxee
                                                              Jul 31 '17 at 21:50


















                                                            • an example would have been helfpful.
                                                              – nyxee
                                                              Jul 31 '17 at 21:50
















                                                            an example would have been helfpful.
                                                            – nyxee
                                                            Jul 31 '17 at 21:50




                                                            an example would have been helfpful.
                                                            – nyxee
                                                            Jul 31 '17 at 21:50


















                                                            draft saved

                                                            draft discarded




















































                                                            Thanks for contributing an answer to Stack Overflow!


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.





                                                            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                            Please pay close attention to the following guidance:


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.




                                                            draft saved


                                                            draft discarded














                                                            StackExchange.ready(
                                                            function () {
                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17246991%2fhow-to-retrieve-more-than-1000-rows-from-parse-com%23new-answer', 'question_page');
                                                            }
                                                            );

                                                            Post as a guest















                                                            Required, but never shown





















































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown

































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown







                                                            Popular posts from this blog

                                                            Bressuire

                                                            Vorschmack

                                                            Quarantine