【问题标题】:Returning all records in Grails返回 Grails 中的所有记录
【发布时间】:2015-03-25 05:57:37
【问题描述】:

我在 grails 中有一个 Domain 类,如下所示:

@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'}
    }
 }
}

我没有这个类的控制器。这个类只检索我 10 条记录。我怎样才能从表中获取所有记录?

P.S:我可以使用控制器来实现这一点,但我不想在这里有一个控制器。我希望我的域类来做到这一点。谢谢

【问题讨论】:

    标签: grails grails-orm


    【解决方案1】:

    没有这样的选项来获取所有记录,但我们可以告诉 grails 返回固定数量的资源,例如: http://localhost:8080/TNMRest/v1/configuration?max=10000 这将返回 10000 记录。 http://localhost:8080/TNMRest/v1/configuration?max=200 返回 200 记录

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      • 2019-12-27
      • 1970-01-01
      相关资源
      最近更新 更多