Search code examples
iosparse-platformpfquery

PFQuery Only Returning 100


I thought that the PFQuery was supposed to have a limit of 1000, but I am having an issue of it only returning 100 objects using this code:

- (id)initWithCoder:(NSCoder *)aDecoder
{
    NSLog(@"initwithcoder");
    self = [super initWithCoder:aDecoder];
    if (self) {
        NSLog(@"self");
        // The className to query on
        self.parseClassName = @"Directory";

        // Whether the built-in pull-to-refresh is enabled
        self.pullToRefreshEnabled = YES;

        // Whether the built-in pagination is enabled
        self.paginationEnabled = NO;

        // The number of objects to show per page
        self.objectsPerPage = 0;


    }
    return self;
}
- (PFQuery *)queryForTable {
    NSLog(@"QUERY");
    PFQuery *query = [PFQuery queryWithClassName:@"Directory"];
    // If no objects are loaded in memory, we look to the cache first to fill the table
    // and then subsequently do a query against the network.
    if (self.objects.count == 0) {
        query.cachePolicy = kPFCachePolicyCacheThenNetwork;
    }
    NSLog(@"Count%lu", self.objects.count);
    [query orderByAscending:@"title"];

    return query;
}

I've tried using '0' as well as '500' or '1000' with no change. Even setting it to a low count of 2 still returns 100, so it's as if my app is completely ignoring that line of code.


Solution

  • The default limit is 100.

    http://parseplatform.org/Parse-SDK-iOS-OSX/api/Classes/PFQuery.html#/Paginating%20Results

    A limit on the number of objects to return. The default limit is 100, with a maximum of 1000 results being returned at a time.

    So just call:

    query.limit = xxx
    

    This was added in Parse Server v2.1.0:

    Fix: Making a query without a limit now returns 100 results Reference: https://github.com/parse-community/parse-server/blob/master/CHANGELOG.md#210-2172016

    Source code: https://github.com/parse-community/parse-server/blob/master/src/Routers/ClassesRouter.js#L117


    There's also a related parameter named maxLimit which is server-wide and represents the Max value for limit option on queries, defaults to unlimited