开发者

Removing null records from a set in Grails Controller

so, Grails is making me feel quite stupid again, I'm new to this. I have A grails domain that maps a table thats in production on a postgresql database. I am trying to track progress on the project by a date field 'migratedDate'. Everytime a process takes place the field is timestamped.

I can't seem to make a controller that populates a map with only non-null values. Everything I've tried is returning all records to the view. What can I add to say:

def list3 = {
    [tape : Tapes.list(sort:"migratedDate", order:"asc")]
}

so that the cont开发者_Python百科roller can remove any records where 'migratedDate' is null

I'm sure I'm missing something simple.

Thanks!


Try this:

def myAction = {
    def c = Tape.createCriteria()
    def tapes = c.list(sort: 'migratedDate', order: 'asc') {
        isNotNull('migratedDate')
    }
    [tape: tapes]
}


With Dynamic Finders

def list3 = {
    [tape : Tapes.findAllByMigratedDateIsNotNull([sort:"migratedDate", order:"asc"])]
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜