我是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” –