0

I have a domain class that looks like this

class A {
static searchable = {
    only: ['title','startAt', 'endAt']
}
....
Date startAt
Date endAt
}

and I use a code like this to search

Date today = new Date()
Date endDate = today + 7
def results = A.search(params, {
.....
            le("A.startAt", today)
            ge("A.endAt", endDate)

        }).results

the problem is that the comparison with dates dont worked,

i tried also like this :

class A {
static searchable = {
    only: ['title','startAt', 'endAt']
    startAt format: "yyyyMMdd"
    endAt format: "yyyyMMdd"
}
....
Date startAt
}

and in for search

def results = A.search(params, {
.....
            le("A.startAt", today.format("yyyyMMdd"))
            ge("A.endAt", endDate.format("yyyyMMdd"))

        }).results

but it does not work either

please help me figuring out what I'm doing wrong

1 Answers1

0

finally i find out my error ! i forget to put le and ge inside must{ }

===>

            must{
                le("startAt", searchDay.format("yyyyMMdd"))
            }

            must{
                ge("endAt", today.format("yyyyMMdd"))
            }