PFQuery Only Returning 100

我是研究僧i 提交于 2019-12-13 03:04:46

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/48771677/pfquery-only-returning-100

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!