For example, today we added a unique constraint on to Asset, where the originalAssetId had to be unique per Site.
To do this we added the constraint:
The 'unique' property can also accept a list of properties. The following snippet would make originalAssetId unique by site and state.
static constraints = {
.......
.......
originalAssetId(unique:'site')
.......
.......
}
Check out the grails docs for a full description.
static constraints = {
.......
.......
originalAssetId(unique:['site','state'])
.......
.......
}
No comments:
Post a Comment