1

I'm trying to reduce the time when querying with multiple values of hasKey, thus why we are looking at batchGetItem. I did a small change in the sample project as following regards of the reference from here :

AWSDynamoDBKeysAndAttributes * keysAndAttributes = [ AWSDynamoDBKeysAndAttributes new ];
AWSDynamoDBAttributeValue * attributeValue1 = [ AWSDynamoDBAttributeValue new ];
attributeValue1.S = @"22";
AWSDynamoDBAttributeValue * attributeValue2 = [ AWSDynamoDBAttributeValue new ];
attributeValue2.S = @"18";

keysAndAttributes.keys = @[ @{ @"UserId" : attributeValue1 },
                            @{ @"UserId" : attributeValue2 } ];
keysAndAttributes.consistentRead = @YES;

AWSDynamoDBBatchGetItemInput * batchGetItemInput = [ AWSDynamoDBBatchGetItemInput new ];
batchGetItemInput.requestItems = @{ @"DynamoDB-OM-Sample" : keysAndAttributes };

AWSDynamoDB * awsDynamoDB = [ AWSDynamoDB defaultDynamoDB ];
[ [ awsDynamoDB batchGetItem: batchGetItemInput ]
        continueWithExecutor: [ AWSExecutor mainThreadExecutor ]
                   withBlock: ^ id ( AWSTask * task ) {

                       if ( task.result ) {
                           NSLog ( @"it's working!!" );
                       }
                       else {
                           NSLog ( @"not working... " );
                       }

                       return nil;
                   } ];

but it keeps telling me there's a error :

The provided key element does not match the schema

Also I do see how to set the limit in AWSDynamoDBQueryExpression, Can we do the same thing with batchGetItem ?

Community
  • 1
  • 1
Mia
  • 1,226
  • 1
  • 19
  • 29

0 Answers0