本文整理匯總了Golang中github.com/bboozzoo/q3stats/store.DBConn類的典型用法代碼示例。如果您正苦於以下問題:Golang DBConn類的具體用法?Golang DBConn怎麽用?Golang DBConn使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DBConn類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewWeaponStat
// create new weapon stat and return its ID
func NewWeaponStat(store store.DBConn, ws WeaponStat) uint {
db := store.Conn()
db.Create(&ws)
return ws.ID
}
示例2: NewItemStat
// create new item stat and return its ID
func NewItemStat(store store.DBConn, is ItemStat) uint {
db := store.Conn()
db.Create(&is)
return is.ID
}
示例3: NewPlayerMatchStat
func NewPlayerMatchStat(store store.DBConn, pms PlayerMatchStat) uint {
db := store.Conn()
db.Create(&pms)
return pms.ID
}
示例4: NewAliasOrCurrent
// create or lookup a matching alias and return its ID
func NewAliasOrCurrent(store store.DBConn, newalias Alias) uint {
db := store.Conn()
var alias Alias
db.FirstOrCreate(&alias, newalias)
return alias.ID
}
示例5: ListPlayers
func ListPlayers(store store.DBConn) []Player {
db := store.Conn()
var players []Player
db.Find(&players)
return players
}
示例6: NewMatch
// create new match and return its ID
func NewMatch(store store.DBConn, match Match) uint {
db := store.Conn()
db.Create(&match)
return match.ID
}
示例7: GetAliases
// return alphabetically ordered list of aliases
func GetAliases(store store.DBConn, user uint) []Alias {
var aliases []Alias
store.Conn().
Model(&Alias{}).
Where("player_id = ?", user).
Order("alias").
Find(&aliases)
return aliases
}
示例8: GetAlias
// find alias using alias ID
func GetAlias(store store.DBConn, aliasID uint) *Alias {
db := store.Conn()
var alias Alias
nf := db.First(&alias, aliasID).RecordNotFound()
if nf == true {
return nil
}
return &alias
}
示例9: ListWeaponStats
// list weapon statistics for given player match stat ID
func ListWeaponStats(store store.DBConn, pmsID uint) []WeaponStat {
db := store.Conn()
var ws []WeaponStat
db.Where(&WeaponStat{
PlayerMatchStatID: pmsID,
}).Find(&ws)
return ws
}
示例10: ListItemStats
// list weapon statistics for given player match stat ID
func ListItemStats(store store.DBConn, pmsID uint) []ItemStat {
db := store.Conn()
var is []ItemStat
db.Where(&ItemStat{
PlayerMatchStatID: pmsID,
}).Find(&is)
return is
}
示例11: ListPlayerMatchStat
func ListPlayerMatchStat(store store.DBConn, matchID uint) []PlayerMatchStat {
db := store.Conn()
// locate all players in this match
var pls []PlayerMatchStat
db.Where(&PlayerMatchStat{MatchID: matchID}).
Find(&pls)
return pls
}
示例12: NewPlayer
// create new player returning its ID
func NewPlayer(store store.DBConn, name string, passwordhash string) uint {
player := Player{
Name: name,
PasswordHash: passwordhash,
}
db := store.Conn()
db.Create(&player)
return player.ID
}
示例13: GetPlayer
func GetPlayer(store store.DBConn, pid uint) *Player {
db := store.Conn()
var player Player
notfound := db.First(&player, pid).
RecordNotFound()
if notfound == true {
return nil
}
return &player
}
示例14: FindMatchByHash
func FindMatchByHash(store store.DBConn, hash string) *Match {
db := store.Conn()
var mfound Match
notfound := db.Where("data_hash = ?", hash).
Find(&mfound).
RecordNotFound()
if notfound == true {
return nil
}
return &mfound
}
示例15: ClaimAliasesByPlayer
func ClaimAliasesByPlayer(store store.DBConn, player uint, aliases []string) {
// update aliases set player_id = `player` where aliases in
// `aliases`?
db := store.Conn()
tx := db.Begin()
for _, a := range aliases {
tx.Model(&Alias{}).
Where(&Alias{Alias: a}).
Update("player_id", player)
}
tx.Commit()
}