返回 Grails 中的所有记录
Returning all records in Grails
我在 grails 中有一个 Domain
class:
@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'}
}
}
}
我没有这个 class.This 的控制器 class 只能检索 10 records.How 我可以从 table 获取所有记录吗?
P.S :我可以使用控制器实现此目的,但我不想拥有控制器 here.I 希望我的域 class做 this.Thanks
没有这样的选项来获取所有记录,但我们可以告诉 grails return 固定数量的资源 ex:
http://localhost:8080/TNMRest/v1/configuration?max=10000
这 returns 10000
条记录。
http://localhost:8080/TNMRest/v1/configuration?max=200
returns 200
条记录
我在 grails 中有一个 Domain
class:
@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'}
}
}
}
我没有这个 class.This 的控制器 class 只能检索 10 records.How 我可以从 table 获取所有记录吗?
P.S :我可以使用控制器实现此目的,但我不想拥有控制器 here.I 希望我的域 class做 this.Thanks
没有这样的选项来获取所有记录,但我们可以告诉 grails return 固定数量的资源 ex:
http://localhost:8080/TNMRest/v1/configuration?max=10000
这 returns 10000
条记录。
http://localhost:8080/TNMRest/v1/configuration?max=200
returns 200
条记录