groovy - GORM/Grails :: possible to query based on contents of a List within the model? -
assume following:
class thing { string name list<string> tags static constraints = { name(nullable: false) tags(nullable: false) } } i want know if possible, using gorm, run query domain instances based on values in respective lists
for instance: there dynamic gorm finders query things 'find things have tag "video" ', or 'find things name = "product1" have tag "image" '
just want know if there's nice concise way of doing grails&gorm, opposed retrieving list of things , iterating through it, finding ones have appropriate tags , adding them results list.
thanks!
one way (although not efficient!) return whole list of things eg thing.list() , filter resulting list using findall.
list results = thing.list().findall{it.tags.contains("image")}
how big list of things , associated tags be?
Comments
Post a Comment