我是DynamoDb
東西的新手。我只想知道如何使用hashKey
和rangeKey
在DynamoDB中的表上查詢。如何在基於HashKey和range key的DynamoDB中執行查詢?
比方說,我的表是TestTable
,它的模式是這樣的:
1.Id (HK of type String)
2 Date (RK of type String)
3 Name (attribute of type String)
現在,如果我要對hashKey
在此基礎上爲Id
這裏在此表中查詢,我們做一個query
爲:
比方說我的查詢是讓有所有項目Id ="123".
TestTable testTable = new TestTable();
testTable.setId("123");
DynamoDBQueryExpression<TestTable> queryExpression = new DynamoDBQueryExpression<TestTable>()
.withHashKeyValues(TestTable)
.withConsistentRead(false);
現在我想要獲得所有具有Id ="123" and Date ="1234"
的項目。
我如何可以查詢DynamoDB
這件事情我使用java
作爲我的編程語言。
嘿..我看了你已經......文章這的確是一個不錯的one.Actually我不想讓這樣的條件用於範圍鍵操作。沒有其他方法嗎? –
我看到的其他可能性(但尚未嘗試過)是使用低級Java查詢api:http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryingJavaDocumentAPI.html QuerySpec( ).withKeyConditionExpression(「Id =:v_id and Date =:v_date」)。withValueMap(new ValueMap()。withString(「:v_id」,「123」).withString(「:v_date」,「1234」 –