阻止 gorm 抱怨 where 子句中的未知列‘users.deleted_at’

stop gorm from complaining about Unknown column ‘users.deleted_at’ in where clause

如何阻止 gorm 抱怨 deleted_at 字段。我知道我可以在没有 gorm.Model 的情况下使用普通结构 但这意味着我 无法将关系添加到 user/other 结构 ... 例如如果我不添加 gorm.Model,我不能声明用户在用户结构中有一种语言关联,但如果我添加,它会抱怨 deleted_at 字段当然不存在.非常感谢任何帮助。我尝试了一些标签组合,例如我添加了 DeletedAt 字段并给它标签 1.gorm: “-” 然后我也尝试 json: “-” 忽略它,但仍然没有运气 这看起来非常基础,但我无法理解抱歉我是 golang 的新手。

我在 conventions of gorm docs

中找到了答案

我刚刚创建了自己的基础模型,而不是使用 gorm.Model 并且没有在其上使用 deleted_at 字段。它工作得很好。

编辑: 看来我错了,我可以有任何基本结构和关联都可以。只是不要将 gorm.Model 用作基本模型。