Reputation: 69
So I was wondering how would I search a secondary domain instance if that domain had a variable that was a primary domain instance:
def postFieldTripList = PostFieldTrip.createCriteria().list(sort: params.sort, order: params.order)
{
and
{
'in' ("fieldTrip.location", ["fieldTrip.%${params.fieldTrip}%"]) //figure out how to search by trip location
}
}
So there is a domain with locations I can add and the Post Fieldtrip domain can call on that particular location normally but how would I create this criteria where I can search by a location name?
Upvotes: 0
Views: 123
Reputation: 33963
Yes you can reference the field in a bracket syntax:
def postFieldTripList = PostFieldTrip.createCriteria().list(sort: params.sort, order: params.order)
{
fieldTrip
{
'in' ("location", ["fieldTrip.${params.fieldTrip}"])
}
}
(The and
is implied and not necessary.)
Upvotes: 1