I am trying to figure out how to compose a batch read operation using AWSiOSSDKv2. I can't seem to find any documentation or examples of this.
To test I am attempting to create a batch read request against a single table, "prod_content_list". This table only has a single primary hash key defined on attribute, "id". The table does not have any range or secondary indexes.
This is what I have so far:
public func getContentEntries(){
// define the primary hash key
var hashAttribute = AWSDynamoDBAttributeValue()
hashAttribute.S = "54c2af81a4f36"
// define an equality condition
var hashCondition = AWSDynamoDBCondition()
hashCondition.comparisonOperator = .EQ
hashCondition.attributeValueList = [hashAttribute]
// add attribute to keys map
let keys:Array = [["id":hashCondition]]
// create AWSDynamoDBKeysAndAttributes instance and assign contentListAttributeMap
let contentListAttributeMap = AWSDynamoDBKeysAndAttributes()
contentListAttributeMap.keys = keys
// create a table map; mapping table name to keys map(single table in this example)
let tableMap = ["prod_content_list" : contentListAttributeMap]
var request = AWSDynamoDBBatchGetItemInput()
request.requestItems = tableMap
request.returnConsumedCapacity = AWSDynamoDBReturnConsumedCapacity.Total
var client = AWSDynamoDB(forKey: "USWest2DynamoDB")
var response = client.batchGetItem(request)
if(response.error != nil){
// Check for error
}else if(response.exception != nil){
// Check for exception
}else{
// Get results
let output = response.result
}
}
The above test method does not report any errors or exceptions but the BFTask.result is nil. I'm aware that the BFTask result may be nil if no records can be found but the hash code in my example definitely exists. I have to assume that something is wrong with how I've defined the attribute/key mapping or the table/attribute mapping in my request. Can someone tell me where I am going wrong here?
Thanks