Suppose I have a class User with many Customers (marked with hasMany property).
In the class Customer I mark the owner with belongsTo.
Now when I want to get user’s customers I simply write User.read(params.id).customers
I want a pagination in my test project, so reading the entire customer list doesnt make much sense.. I’d use something like Customer.findAllByOwner but this method is such a method is not present..
How do I limit the result set of such a query then (offset and limit)?
package myapp
class User {
...
static hasMany = [customers: Customer]
...
}
package myapp
class Customer {
...
static belongsTo = User
...
}
Correct me if I’m wrong, but the idea in its most simplistic form here is that you want to get a list of Customers based off of the User object.
In that case, change your Customer domain class to something like…
Then, in your controller you can do something like:
Hope this helps.