Is there a way to use findWhere
and a not equal value (trying to use it vs criterias)?
E.g.
Books.findWhere('sale' : true, 'category': ne('exclude me') )
I have a working solution, but was wondering if there was a way to use findWhere
I find it simpler to read.
def result = Books.createCriteria().get{
eq('sale', true)
ne("category", 'exclude me')
}
You can use either the dynamic finder methods:
Books.findAllBySaleAndCategoryNotEqual(true, 'exclude me')
or the where queries (which use DetachedCriteria
:
Books.findAll {
(sale == true) && (category != 'exclude me')
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With