PFQuery 只返回 100

PFQuery Only Returning 100

我认为 PFQuery 应该有 1000 个的限制,但我遇到了一个问题,它使用以下代码只返回 100 个对象:

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

我试过使用“0”以及“500”或“1000”,没有任何变化。即使将它设置为 2 的低计数仍然 returns 100,所以就好像我的应用程序完全忽略了那行代码。

默认 limit 为 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.

所以只要打电话:

query.limit = xxx

这是在 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

源代码:https://github.com/parse-community/parse-server/blob/master/src/Routers/ClassesRouter.js#L117


还有一个名为 maxLimit 的相关参数,它是服务器范围的,代表 Max value for limit option on queries, defaults to unlimited