How to query the greates value (sortkey/range) dyn

2019-07-25 09:02发布

问题:

Maybe this is a very simple question but I didn't find a suitable solution for this. I have a secondary key /range key /sort key, what ever and its value is a number. So in the Table a several items with this key and I want to get the Item with the greatest number/value. I found this at stack overflow but this does not look like something from the aws documentation. In this documentation you can find gt or ge but I don't want to compare the value with a number, I want the greatest ... Maybe you can help

回答1:

If the property you want to query is your sort/range key, you only need to set ScanIndexForward=false (order descending) and set the Limit to 1