【发布时间】:2015-12-25 10:41:15
【问题描述】:
使用go 1.5 和gorm。
假设我想创建一个包含 created_by_id 和 updated_by_id 列的 events 表。
我写我的模型像
type By struct {
ByID sql.NullInt64
By *User
}
type CreatedBy struct {
By
}
type UpdatedBy struct {
By
}
type Event struct {
CreatedBy
UpdatedBy
}
当我尝试保存event 对象时,将尝试保存by_id 列的值,而不是created_by_id 和updated_by_id 的值。我需要做什么来确保ByID 属性的列名对于CreatedBy 和UpdatedBy 是不同的?
【问题讨论】:
-
嗨..我不明白这个问题。你能补充一些信息吗?