Gorp Transient
テーブルに無いフィールド使いたい (矛盾) modelに入れたい
type ColumnMap
https://godoc.org/github.com/coopernurse/gorp
type ColumnMap struct { // Column name in db table ColumnName string // If true, this column is skipped in generated SQL statements Transient bool // If true, " unique" is added to create table statements. // Not used elsewhere Unique bool // Passed to Dialect.ToSqlType() to assist in informing the // correct column type to map to in CreateTables() // Not used elsewhere MaxSize int // contains filtered or unexported fields }
使い方
gorp.go
t := Dbm.AddTable(models.User{}).SetKeys(true, "UserId") t.ColMap("Password").Transient = true setColumnSizes(t, map[string]int{ "Username": 20, "Name": 100, })
勉強なります。