package account import ( "time" "github.com/rs/zerolog/log" "xorm.io/xorm" ) // Account handler type Account struct { db *xorm.Engine } // Account model type Model struct { ID int64 Username string `xorm:"varchar(30) unique"` Password string `xorm:"varchar(90)"` Admin bool Created time.Time `xorm:"created"` } // Return a new Account func New(engine *xorm.Engine) *Account { // Sync engine err := engine.Sync(new(Model)) if err != nil { log.Panic().Msg(err.Error()) } return &Account{db: engine} }