gpt4 book ai didi

grails findWhere 不相等

转载 作者:行者123 更新时间:2023-12-04 19:10:43 26 4
gpt4 key购买 nike

有没有办法使用 findWhere 和不相等的值(尝试使用它与标准)?

例如。

Books.findWhere('sale' : true, 'category': ne('exclude me') )

我有一个可行的解决方案,但想知道是否可以使用 findWhere我觉得读起来更简单。
def result = Books.createCriteria().get{
eq('sale', true)
ne("category", 'exclude me')
}

最佳答案

您可以使用动态查找器方法:

Books.findAllBySaleAndCategoryNotEqual(true, 'exclude me')

或 where 查询(使用 DetachedCriteria :
Books.findAll {
(sale == true) && (category != 'exclude me')
}

关于grails findWhere 不相等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15480158/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com