The following grails query will limit the number of results to 3, and then sort them by id:
def results = Domain.findAllByFoo(foo, [sort: 'id', order: 'desc', max: 3])
This way, it will return identifiers 1 through 3, and then change their order, so that
results*.id == [3,2,1]
Is there a way to sort first and restrict it so that
results*.id == [99,98,97]
My current workaround is this:
if (results.size() > max) results = results[0..<max]
source share