簡體   English   中英

GORM-使用mongoDB時似乎忽略了唯一約束

[英]GORM - unique constraint seems to be ignored when using mongoDB

這是域類:

class User {
    String name
    String email

    static constraints = {
        name()
        email(unique: true)
    }
}

當我調用保存方法並創建重復記錄時,將忽略電子郵件的唯一屬性。 我在這里想念什么嗎?

找到了解決方案:

 static mapping = {
    email index:true, indexAttributes: [unique:true]
 }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM