dynamodb scanexpression with scan filter in objective-c

末鹿安然 提交于 2019-12-22 17:38:13

问题


    AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
    AWSDynamoDBScanExpression *scanExpression = [AWSDynamoDBScanExpression new];
    scanExpression.exclusiveStartKey = nil;
    scanExpression.limit = @20;
    [[[dynamoDBObjectMapper scan:[DDBTableRow class]
                      expression:scanExpression]
      continueWithExecutor:[BFExecutor mainThreadExecutor] withSuccessBlock:^id(BFTask *task) { ................

I am able to scan through and return the first 20 recorded from a specific table from my DynamoDB as shows on a piece of code above.

The question now is I want to add a scanExpression.scanFilter = property but I haven't find any good direction on how to build that. I am using AWSiOSSDKv2 aws sdk for iOS on xcode6

here is what I have so far. It is not complete yet:

    AWSDynamoDBCondition *condition = [AWSDynamoDBCondition new];
    AWSDynamoDBAttributeValue *attribute = [AWSDynamoDBAttributeValue new];
    attribute.N = @"400";
    condition.comparisonOperator = AWSDynamoDBComparisonOperatorEQ;

    NSDictionary *scanFilter = @{@"lat":
                                     @{@"AttributeValueList":attribute,
                                       @"ComparisonOperator":@1}
                                 };
    scanExpression.scanFilter = scanFilter;

回答1:


You can use it as follows:

AWSDynamoDBCondition *condition = [AWSDynamoDBCondition new];
AWSDynamoDBAttributeValue *attribute = [AWSDynamoDBAttributeValue new];
attribute.N = @"400";
condition.attributeValueList = @[attribute];
condition.comparisonOperator = AWSDynamoDBComparisonOperatorEQ;
scanExpression.scanFilter = @{@"lat": condition};


来源:https://stackoverflow.com/questions/25792359/dynamodb-scanexpression-with-scan-filter-in-objective-c

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