0

ページングで Google Cloud Endpoints を使用する方法を理解しようとしています。10件の結果しか返ってきません。プロパティ shouldFetchNextItems を YES に設定しました。また、クエリ オブジェクトには nextToken または maxResults プロパティがありません。pageToken を持つ GTLQueryCollectionProtocol がありますが、それがどこで使用されているかわかりません。

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)

ありがとう、

4

1 に答える 1

1

ドキュメントからページングのサンプルを確認してください。

ページング パラメータを API に含めるには、メソッドに明示的に含める必要があります。

@Brand.query_method(query_fields=('limit', 'pageToken'),
                    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)

クエリ制限のデフォルト値は です10。変更することはできますが、妥当な値を設定する必要がありますlimit。のlimit_defaultフィールドですquery_method

于 2013-07-10T23:40:23.513 に答える