如何仅使用主键查询/扫描 DynamoDB 表?我能够从表中返回结果的唯一方法是下面的代码,我在其中设置了主键Id并Condition使用排序键添加了 a Date。有什么方法可以在不提供 的情况下查询表RangeKeyCondition?DynamoDataObject data = new DynamoDataObject();data.setId(userId);Condition rangeKeyCondition = new Condition() .withComparisonOperator(ComparisonOperator.BEGINS_WITH) .withAttributeValueList(new AttributeValue().withS("2018"));DynamoDBQueryExpression queryExpression = new DynamoDBQueryExpression() .withHashKeyValues(data) .withRangeKeyCondition("Date", rangeKeyCondition) .withConsistentRead(false);PaginatedList<DynamoDataObject > result = AWSProvider.getInstance().getDynamoDBMapper().query(DynamoDataObject.class, queryExpression);Log.d(TAG, "PaginatedList length: " + result.size());
1 回答
qq_遁去的一_1
TA贡献1725条经验 获得超7个赞
弄清楚了。您不必包括withRangeKeyCondition:
DynamoDataObject data = new DynamoDataObject();
data.setId(userId);
DynamoDBQueryExpression queryExpression = new DynamoDBQueryExpression()
.withHashKeyValues(data)
.withConsistentRead(false);
PaginatedList<DynamoDataObject > result = AWSProvider.getInstance().getDynamoDBMapper().query(DynamoDataObject.class, queryExpression);
Log.d(TAG, "PaginatedList length: " + result.size());
添加回答
举报
0/150
提交
取消