Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the dynamoDB's primary key list

I would like to extract the primary key of table to a list , but find no api to do that.

for example, as the amazon example thread table, I want to ask how to :

1) get the hash primary key list, in the amazon example thread table it would be an array of ["Amazon DynamoDB", "Amazon S3"]

2) with assigning the hash primary key to "Amazon DynamoDB", I want to get the range primary key list and it would be an array of ["Amazon DynamoDB Thread 1", "Amazon DynamoDB Thread 2"]

like image 729
Yehudi Avatar asked Oct 25 '13 07:10

Yehudi


People also ask

Is there a primary key in DynamoDB?

There are two types of primary keys in DynamoDB: Partition key: This is a simple primary key. If the table has only a partition key, then no two items can have the same partition key value. Composite primary key: This is a combination of partition key and sort key.

How do I find my DynamoDB access key?

Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/ . In the navigation pane, choose Users. Choose the name of the user whose access keys you want to create, and then choose the Security credentials tab. In the Access keys section, choose Create access key.

Can you query by sort key only DynamoDB?

You can not query only using a Sort Key. You need to specify a partition key to perform query operations. Else, you need to create a global secondary index or perform a scan operation.

Which API call would you use to query an item by its primary key?

With the DynamoDB API, you use the PutItem operation to add an item to a table. DynamoDB provides the GetItem action for retrieving an item by its primary key.


1 Answers

For 1 what you want is to run a Scan operation on a table. Scan Gets all the items of the list. Depends on the API you are using, you can get only the hash key or any attributes you want.

For 2 what you want is Query - which gets a hash attribute and returns all rows that have the hash attribute (can be more than one).

Overview - Query and Scan operations

Java mapper reference - Scan and Query

like image 134
Chen Harel Avatar answered Sep 29 '22 12:09

Chen Harel