0
這裏是域類GORM - MongoDB中不會對父類保存項目設置
class Settings {
static constraints = {
uid(nullable: false, unique: true)
data()
}
static hasMany = [items: Item]
Map data
}
class Item{
static constraints = {
name()
email()
approved()
}
static mapping = {
email index: true, indexAttributes: [unique: true]
}
String name
String email
Boolean approved = false;
}
基本上有有許多項目的許多設置對象(見插圖下面):
現在我找到並更新像這樣的項目:
...
def item = (Item)Item.findByEmail(email);
if (!item.approved) {
item.approved = true;
item.save(flush: true);
}
...
未保存我缺少什麼嗎?