我在想如何列出Grails域並同時排除某些字段。我猜測解決方案一定很簡單,但我看不到它。如何在列出Grails域時排除某些字段?
我準備了一些例如與域用戶:
class User implements Serializable {
String username
String email
Date lastUpdated
String password
Integer status
static constraints = { }
static mapping = { }
}
在這一點上,我想列出具有低於2
render User.findAllByStatusLessThen(2) as JSON
我想渲染JSON應答,而不向客戶方狀態的所有用戶一些領域。例如,我只想渲染領域用戶名和LASTUPDATED所以呈現JSON看起來像這樣的用戶:
[{"username": "user1", "lastUpdated":"2016-09-21 06:49:46"}, {"username": "user2", "lastUpdated":"2016-09-22 11:24:42"}]
什麼是實現這一目標的最簡單的方法?
感謝您的優勢你的意見。解決方案2適合我的情況。 – matox