Josh K
Josh K

Reputation: 28883

Using .list() in Grails with other query options

I would like to use the .list call with another query (for example a date range or all of a certain type). Is this possible or do I need to build a custom .find call wrapping all the options in .list like offset and max?

Upvotes: 1

Views: 2147

Answers (2)

uchamp
uchamp

Reputation: 2512

You can try something like:

filter = { it.datePublished >= 'date1' && it.datePublished <= 'date2' }
def filteredList = Book.list(max: 10, offset: 100).collect(filter)

Upvotes: 0

Jarred Olson
Jarred Olson

Reputation: 3243

You'll probably want to look at the Dynamic Finders and/or Where Queries sections of the Grails doc. If you want to give a more specific example of what you're trying to accomplish I can better answer your questions.

Upvotes: 2

Related Questions