使用扫描操作从DynamoDB表获取分页输出

时间:2016-05-01 23:13:51

标签: ios objective-c amazon-dynamodb

我在DynamoDB表上进行扫描操作。代码如下。

我能够获得第一页的结果,其中限制由" scanExpression.limit"定义,但是如何获得连续的页面?

    AWSDynamoDBScanExpression *scanExpression = [AWSDynamoDBScanExpression new];
    scanExpression.limit = @10;

    [[dynamoDBObjectMapper scan:[Post class]
                     expression:scanExpression]
     continueWithBlock:^id(AWSTask *task) {
         if (task.error) {
             NSLog(@"The request failed. Error: [%@]", task.error);
         }
         if (task.exception) {
             NSLog(@"The request failed. Exception: [%@]", task.exception);
         }
         if (task.result) {
             AWSDynamoDBPaginatedOutput *paginatedOutput = task.result;
             for (Post *post in paginatedOutput.items) {

                 if (arraycount == 0){
                     [_FeedImageURL addObject:post.ImageURL];}
                 }
                 else{
                     [_FeedImageURL insertObject:post.ImageURL atIndex:arraycount];
                 }

                 arraycount=arraycount +1;

             }
         }

         return nil;
     }];

0 个答案:

没有答案