iberck
3/9/2017 - 3:28 AM

Grails query list

Grails query list

List

Sirve para obtener la lista de las instancias de un domain class

// list everything
def results = Book.list()

// list 10 results
def results = Book.list(max: 10)

// list order by asc
def results = Book.list(sort: "title", order: "asc")

// list 10 results, offset by 100
def results = Book.list(max: 10, offset: 100)

// list 10 results, offset by 100, orderd by title in descending order
def results = Book.list(max: 10, offset: 100, sort: "title", order: "desc")

// list all books, eagerly fetching the authors association
def results = Book.list(fetch: [authors: "eager"])

http://docs.grails.org/2.5.x/ref/Domain%20Classes/list.html