I am having a dynamo db with a GSI on GSI_ID and range key on lastUpdatedId attribute. I want only 1 task to be rendered which is the latest on the basis of match. This is the expression I am using
DynamoDBQueryExpression<Record> exp =
new DynamoDBQueryExpression<GoldDataRecord>()
.withIndexName(GSI_ID)
.withKeyConditionExpression(KEY_EXP)
.withExpressionAttributeValues(attrValues)
.withLimit(1)
// to get the results in descending order of last updated date giving the latest data first
.withScanIndexForward(false)
.withSelect(Select.ALL_ATTRIBUTES)
.withConsistentRead(false);
private DynamoDBMapper dynamoDBMapper;
PaginatedQueryList<Record> res = dynamoDBMapper.query(Record.class, exp);
But it is fetching all the records that are matching the GSI. What am I doing wrong here?
question from:
https://stackoverflow.com/questions/65917329/fetch-n-latest-records-from-dynamo-db 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…