本文整理匯總了Golang中github.com/coopernurse/gorp.DbMap.AddTable方法的典型用法代碼示例。如果您正苦於以下問題:Golang DbMap.AddTable方法的具體用法?Golang DbMap.AddTable怎麽用?Golang DbMap.AddTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coopernurse/gorp.DbMap
的用法示例。
在下文中一共展示了DbMap.AddTable方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RegSchema
func RegSchema(dbmap *gorp.DbMap) {
dbmap.AddTable(Entry{}).SetKeys(true, "Id")
err := dbmap.CreateTables()
if err != nil {
fmt.Println(err)
return
}
}
示例2: Serve
// Serve starts the RPC server on listener. Serve blocks.
func Serve(listener net.Listener, dbmap *gorp.DbMap) error {
dbmap.AddTable(UniVar{}).SetKeys(false, "Name")
err := dbmap.CreateTablesIfNotExists()
if err != nil {
return err
}
server := &Elvishd{dbmap}
rpc.Register(server)
rpc.Accept(listener)
return nil
}
示例3: AddTables
func AddTables(dbm *gorp.DbMap) {
dbm.AddTable(Game{}).SetKeys(true, "Id")
dbm.AddTable(Organization{}).SetKeys(true, "Id")
dbm.AddTable(Player{}).SetKeys(true, "Id")
dbm.AddTable(User{}).SetKeys(true, "Id")
dbm.AddTable(Oz{}).SetKeys(true, "Id")
dbm.AddTable(Tag{}).SetKeys(true, "Id")
dbm.AddTable(Member{}).SetKeys(true, "Id")
dbm.AddTable(Event{}).SetKeys(true, "Id")
dbm.AddTableWithName(EventType{}, "event_type").SetKeys(true, "Id")
dbm.AddTableWithName(EventTag{}, "event_tag")
dbm.AddTableWithName(EventPlayer{}, "event_player")
dbm.AddTableWithName(EventRole{}, "event_role").SetKeys(true, "Id")
dbm.AddTableWithName(EventToPlayer{}, "event_to_player").SetKeys(true, "Id")
dbm.AddTableWithName(EventToGame{}, "event_to_game").SetKeys(true, "Id")
dbm.AddTableWithName(HumanCode{}, "human_code").SetKeys(false, "Id")
dbm.AddTableWithName(OzPool{}, "oz_pool").SetKeys(true, "Id")
dbm.AddTableWithName(PasswordReset{}, "password_reset")
}
示例4: defineBidItemTable
// using 'define' and not 'create' - because db is not actually created until call to Dbm.CreateTablesIfNotExists()
func defineBidItemTable(dbm *gorp.DbMap) {
// set "id" as primary key and autoincrement
t := dbm.AddTable(models.BidItem{}).SetKeys(true, "id")
// e.g. VARCHAR(25)
t.ColMap("name").SetMaxSize(25)
}
示例5: RegSchema
func RegSchema(dbmap *gorp.DbMap) {
dbmap.AddTable(Category{}).SetKeys(true, "Id")
dbmap.AddTable(EntryInCategory{}).SetKeys(true, "Id")
dbmap.CreateTables()
}