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"]
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With