dptrmt4366 2019-06-10 06:42
浏览 40

SoftDelete和unique_index冲突

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向