I assume that you are invoking a selection of books in the controller or service class.
If you call this from a controller action, then the "params" magic variable is already available to you. For example, if you request a page as follows
book/list?max=10&offset=2
then "params" will already have these values ββautomatically displayed.
You can add several items to the parameter map as follows
params.sort = "dateCreated" params.order = "desc"
Once you create your parameters as you wish, you can use the Grails dynamic query as follows
def books = Book.findAllByApproved(true, params)
source share