Currently, I'm using Spring boot with DynamoDB and using DynamoDBMapper for all DB operation. Right now it's sorting in ascending order based on sort key(field name id). How can I sort in descending order based on sort key value?
Current code :
@Override
public PageImpl getCustomerOrders(Pageable pageable) {
List orders = new ArrayList<>();
Map eav = new HashMap();
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
List exp = new ArrayList<>();
// filters
if (!exp.isEmpty())
scanExpression
.withFilterExpression(String.join(" AND ", exp)).withExpressionAttributeValues(eav);
PaginatedScanList scan = mapper.scan(Order.class, scanExpression);
int start = (int) pageable.getOffset();
int size = scan.size();
int end = (start + pageable.getPageSize()) > size ? size : (start + pageable.getPageSize());
if (start < size)
for (Order o : scan.subList(start, end)) {
orders.add(o);
}
return new PageImpl(orders, pageable, size);
}
After some googling, I found that I need to set ScanIndexForward to be true but still I'm confused that how can I achieve it with DynamoDBMApper?
Or should I need to use any low-level class like DynamoDB or AmazonDynamoDb?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)