问题描述
我可以在AWS dynamoDB中的单个表上执行简单的获取
请求,但是当我将其扩展到跨多个表的批处理请求时,我仍然会收到错误
I can perform a simple Get
request on a singular table within AWS dynamoDB however when I expand it to a Batch Request across multiple tables I continue to get a error
validation error detected: Value null at 'requestItems.rip.member.keys' failed to satisfy constraint
我理解这是因为值没有正确传递但我看不出我的代码有什么问题
I understand this as the values not being passed correctly but I can't see what the issue is with my code
//Create Request Values
AWSDynamoDBGetItemInput *getItem = [AWSDynamoDBGetItemInput new];
AWSDynamoDBAttributeValue *hashValue = [AWSDynamoDBAttributeValue new];
hashValue.S = @"User Test";
getItem.key = @{@"ripId": hashValue};
//Create Request Values 2
AWSDynamoDBGetItemInput *getItem2 = [AWSDynamoDBGetItemInput new];
AWSDynamoDBAttributeValue *hashValue2 = [AWSDynamoDBAttributeValue new];
hashValue2.S = @"User Test";
getItem2.key = @{@"chat": hashValue2};
//Combine to Batch Request
AWSDynamoDBBatchGetItemInput * batchFetch = [AWSDynamoDBBatchGetItemInput new];
batchFetch.requestItems = @{ @"rip": getItem,
@"chat": getItem,};
[[dynamoDB batchGetItem:batchFetch] continueWithBlock:^id(BFTask *task) {
if (!task.error) {
NSLog(@"BOY SUCCES");
} else {
NSLog(@" NO BOY SUCCESS %@",task.error);
}
return nil;
}];
搜索互联网的高低,但无法看到使用iOS Objective C的批量请求的工作示例(或者swift那件事。)
Searched the internet high and low but cannot see a working example of a batch request using iOS Objective C (or swift for that matter).
我已经在一个获取
请求中测试了这两个变量,它们都有效。
I have tested both variables on a single Get
request and they both work.
推荐答案
你忘记在 AWSDynamoDBAttributeValue > AWSDynamoDBKeysAndAttributes 。以下是来自 AWSDynamoDBTests.m :
You forgot to wrap around AWSDynamoDBAttributeValue
in AWSDynamoDBKeysAndAttributes
. Here is a simple example from AWSDynamoDBTests.m:
AWSDynamoDBKeysAndAttributes *keysAndAttributes = [AWSDynamoDBKeysAndAttributes new];
keysAndAttributes.keys = @[@{@"hashKey" : attributeValue1},
@{@"hashKey" : attributeValue2}];
keysAndAttributes.consistentRead = @YES;
AWSDynamoDBBatchGetItemInput *batchGetItemInput = [AWSDynamoDBBatchGetItemInput new];
batchGetItemInput.requestItems = @{table1Name: keysAndAttributes};
这篇关于AWS DynamoDB批量获取请求 - iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!