Database Reference
In-Depth Information
Fetching data
Earlier, we saw how to put data into DynamoDB tables. Now, let's see how to fetch the
stored data back using mobile SDK APIs.
Android
Here is the syntax to fetch the data from a given DynamoDB table:
//specify the key attributes for the record to be fetched
Map<String, AttributeValue> key = new HashMap<String,
AttributeValue>();
key.put("productId", 123);
key.put("recordId", "productName");
// Create request
GetItemRequest getItemRequest = new
GetItemRequest("ProductTable",key);
// Invoke request
GetItemResult getItemResult =
ddbClient.getItem(getItemRequest);
Once you have the result, you can fetch the required attribute from an item.
iOS
Here is the syntax to fetch the data from a given DynamoDB table:
// Create request and specify the table name
DynamoDBGetItemRequest *getItemRequest =
[DynamoDBGetItemRequest new];
getItemRequest.tableName = @"ProductTable";
// Specify the keys for the item to be fetched.
DynamoDBAttributeValue *productId = [[DynamoDBAttributeValue
alloc] initWithN:@"123"];
DynamoDBAttributeValue *recordId = [[DynamoDBAttributeValue
Search WWH ::




Custom Search