Search code examples
grailsgrails-orm

Returning all records in Grails


I have a Domain class in grails like this :

@Resource(uri="/v1/customVanities",formats = ['json'])
class CustomVanity {

   String vanityAbbreviation
   String vanityDescription

   static mapping = {
    table 'ni_vanity_reg_def'
    version false
    vanityAbbreviation column: 'VANITY_FILTER_ABBR'
    vanityDescription column: 'VANITY_FILTER_DESC'
    id column: 'VANITY_FILTER_DEF_PK'
}

static {
    grails.converters.JSON.registerObjectMarshaller(CustomVanity) {
    return it.properties.findAll {k,v -> k != 'class'}
    }
 }
}

I dont have a controller for this class.This class retrieves me only 10 records.How can i get all the records from the table?

P.S : I can achieve this using a controller but i dont want to have a controller here.I want my domain class to do this.Thanks


Solution

  • There is no such options to get all the records but we can tell grails to return a fixed number of resource ex: http://localhost:8080/TNMRest/v1/configuration?max=10000 This returns 10000 records. http://localhost:8080/TNMRest/v1/configuration?max=200 returns 200 records