简体   繁体   中英

List key values in AWS DynamoDB

  1. What would be an example on how to perform a query in AWS DynamoDB using the C++ SDK? I cannot find such an example in TableOperationTest.cpp in "aws-cpp-sdk-dynamodb-integration-tests".

  2. When I use "getItemRequest" to use a hash key to get an item result from DynamoDB, how to can I get the "key value" for the non-hash key?

For example, I have created a dynamo table as follows. "id" is the hash key.

{ "id": "1", "Status": "0", }

getItemRequest.AddKey("id", "1");
getItemRequest.SetTableName("mytablename");
auto getItemOutcome = dynamoDbClient.GetItem(getItemRequest);
GetItemResult result = getItemOutcome.GetResult();
Aws::Map<Aws::String, AttributeValue> returnedItemCollection = result.GetItem();
std::cout << "Status: " << returnedItemCollection["Status"].GetS() << std::endl;

I need to specify the key "Status" to get attribute value using returnedItemCollection["Status"].GetS() . How can I know the item has a key "Status" ?

Do you mean, how can you know what keys are in the result? Perhaps I misunderstand the question, but isn't as simple as this?

for(auto& itemEntry : returnedItemCollection)
{
   std::cout << itemEntry.first << ": " << itemEntry.second.GetS() << std::endl;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM