|
package model // This is actually filename: "model/users.go" |
|
|
|
import ( |
|
. "./myorm" |
|
"time" |
|
) |
|
|
|
|
|
|
|
type User struct { |
|
MODEL |
|
|
|
Id int64 `options:"NOT NULL" PRIMARY_KEY AUTO_INCREMENT` |
|
DisplayName string |
|
Email string `type:"VARCHAR(255)"` |
|
Birthdate time.Time `mysql_type:"date"` |
|
Admin bool |
|
Verified bool |
|
|
|
TABLE `users` |
|
OPTIONS `ENGINE=InnoDB CHARACTER SET utf8` |
|
//myorm.JOIN_FRAGMENT `LEFT JOIN users_xtrainfo ON users.id = users_xtrainfo.` |
|
} |
|
|
|
func init(){ |
|
Connect("DATABASE_USERNAME:DATABASE_PASSWORD@tcp(DATABASE_HOST:3306)/DATABASE_NAME?charset=utf8&parseTime=True&loc=Local") |
|
AutoMigrate(&User{}) // AutoMigrate will automatically create the table and add missing fields. |
|
} |