我想弄清楚如何在分頁中使用Google Cloud Endpoints。我只得到10個結果。我已將屬性shouldFetchNextItems設置爲YES。另外我的查詢對象沒有nextToken或maxResults屬性。有一個帶pageToken的GTLQueryCollectionProtocol,但我沒有看到它在哪裏使用。ios應用程序引擎端點分頁
static GTLServiceOwnit *service = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
service = [[GTLServiceOwnit alloc] init];
service.retryEnabled = YES;
service.shouldFetchNextPages = YES;
});
NSError *error;
NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
GTLQueryOwnit *query = [GTLQueryOwnit queryForBrandList];
[service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, GTLOwnitBrandCollection *object, NSError *clouderror) {
NSLog(@"counts: %d", [[object items] count]);
...
編輯: 這是我在Python後端:
class Brand(EndpointsModel):
name = ndb.StringProperty(required=True)
@Brand.query_method(path='brand',
http_method='GET',
name='brand.list')
def brand_list(self, query):
"""Exposes an API endpoint to query for brands for the current user"""
return query.order(Brand.name)
感謝,
你的後端是什麼樣的?它是Python還是Java?爲什麼你的查詢對象有'nextToken'或'maxResults'屬性? – bossylobster
@bossylobster我用後端代碼更新了我的帖子。我在這裏的例子:http://code.google.com/p/google-api-objectivec-client/wiki/Introduction#Result_Pages其中GTLQueryTasks有一個pageToken和maxResults –