The following grails query will limit the number of results to 3 and then sort those by id:
def results = Domain.findAllByFoo(foo, [sort: 'id', order: 'desc', max: 3])
So this will return ids 1 through 3, and then reverse their order, so that
results*.id == [3,2,1]
Is there a way to sort first, and limit after, so that
results*.id == [99,98,97]
My current workaround is this:
if (results.size() > max) results = results[0..<max]
This was due to a bug in Grails that is fixed in 2.0.4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With