0

I have this Criteria:

def myList =  BAS.createCriteria().list () {
  projections { distinct ( "id" ) 
      property("date")
      property("id")
  }

  carList{ 
      eq("login",login)    
          }

  ccList{
      eq("cmd",false)
        }


  order("date","desc")
}

I want to add also null as a criteria for "cmd". Is there an OR to be used in my case?

Thanks

Joshua Moore
  • 24,706
  • 6
  • 50
  • 73
Jils
  • 783
  • 5
  • 12
  • 32

1 Answers1

4

Yes, there is an OR that you can use in this case.

ccList {
  or {
    eq("cmd", false)
    isNull("cmd")
  }
}

The documentation has this and other options outlined. Further information is also found throughout the rest of the documentation.

Joshua Moore
  • 24,706
  • 6
  • 50
  • 73
  • I already read the documentation but I didn't find how tu use OR. – Jils Jan 17 '14 at 09:34
  • @Jils No worries, glad I could give you an example then. – Joshua Moore Jan 17 '14 at 10:28
  • "The documentation has this and other options outlined." -- no it does not. There's no explanation at all about `and` / `or` clauses on that page. – Desty Feb 03 '16 at 17:12
  • 1
    @Desty The link is to just a section of the documentation, I expected someone to be able to go through and read the relevant sections. However, based on your helpful and positive comment I have edited the answer to link to the specific section regarding GORM criteria. Enjoy! – Joshua Moore Feb 03 '16 at 18:41
  • @JoshuaMoore I get the feeling that you feel my comment was actually *not* in a positive tone. Indeed, I was frustrated having spent some time searching for information and failing, assuming that they were actually undocumented on the Grails site. Thanks for proving me wrong, and please accept my apologies. – Desty Feb 04 '16 at 11:18