Grails findAll with sort, order, max and offset?

前端 未结 4 1476
时光取名叫无心
时光取名叫无心 2021-02-19 18:25

I want to integrate sort, order, max and offset in a findAll query. The following works fine:

def books = Book.findAll(\"from Book as b where b.approved=true ord         


        
4条回答
  •  长情又很酷
    2021-02-19 18:43

    Using a where query works for me:

    def books = Book.where{approved == true}.list(sort: 'dateCreated', order: 'desc', max: max, offset: offset)

    Or with params straight from the page:

    def books = Book.where{approved == true}.list(params)

提交回复
热议问题