I would like to store an email address in my table users and be certain that this address is not already present, for that I chose the parameter unique_index
, by congress if a user removes his account and wishes the create it later, it can not because the unique_index
message is displayed while it isdeleted_at
.
Do you know if there is a better method with Gorm to treat this case?
type User struct {
Base
Name string `json:"name" gorm:"name;"`
Email string `json:"email" gorm:"email;unique_index"`
Password string `json:"password" gorm:"password;"`
}
to add :
user := new(model.User)
[...]
db.Create(&user)
Thanks for your help