0

I am trying to query all of the users of my app, and am using a PFQuery to do this. Here is the code I am using:

  PFQuery *query = [PFUser query];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error) {
        // The find succeeded. The first 100 objects are available in objects
        NSLog(@"%lu", (unsigned long)objects.count);
    } else {
        // Log details of the failure
        NSLog(@"Error: %@ %@", error, [error userInfo]);
    }
}];

This code works but only gets the first 100 users. When I want to get all of mine, anyone know how to edit this or another way to write a query that will get all the users?

Thanks in advance.

2 Answers2

3

You will have to set the limit of the query using query.limit, as well as query.skip to skip the users you have already queried. If you don't want to do this you can write and call a cloud code function that will return all of the users at once.

Jacob
  • 2,338
  • 2
  • 22
  • 39
  • 2
    Just to add to this, the max limit you can set is 1,000, and the max you can skip is 10,000. Once you exceed this many users you'll need to think of other solutions (starting with why on earth you need to load more than 10,000 User objects client-side!). – Timothy Walters Aug 13 '14 at 09:39
  • @TimothyWalters Thanks Tim! I answered from my phone so I didn't have time to add all of that, that's why I mentioned the cloud code quickly. – Jacob Aug 13 '14 at 11:04
  • @Jacob I realized loading all even 100 users data client side takes a lot of time. I am currently working on sending push notifications to users. And basically I want to check whether a user has favorited an item and if they have send them a notification. Would could code be the best way to go about this? And I would want it to run every day lets say... Thanks for your help –  Aug 13 '14 at 20:52
  • @spenf I would start a new question for this because this question was already taken care of :) – Jacob Aug 13 '14 at 21:05
0

You will have to set the limit of the query using query.limit,

And then you have have to skip the others

iqueqiorio
  • 1,149
  • 2
  • 35
  • 78