Search code examples
grailsgrails-orm

efficient way to get last two records in grails?


I have a domain class say

class Content{

  String content
  Date dateCreated
  Date lastUpdated

}

There are few content records in the database. I want to retrieve the latest two records. What is an efficient way to query two latest records in Grails? Thanks!


Solution

  • Isn't

    Content.list(max: 2, sort: "dateCreated", order: "desc")
    

    a possibility?