當前位置: 首頁>>代碼示例>>Golang>>正文


Golang store.DBConn類代碼示例

本文整理匯總了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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:8,代碼來源:weapon.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:8,代碼來源:item.go

示例3: NewPlayerMatchStat

func NewPlayerMatchStat(store store.DBConn, pms PlayerMatchStat) uint {
	db := store.Conn()

	db.Create(&pms)

	return pms.ID
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:7,代碼來源:playermatch.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:9,代碼來源:alias.go

示例5: ListPlayers

func ListPlayers(store store.DBConn) []Player {
	db := store.Conn()

	var players []Player
	db.Find(&players)

	return players
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:8,代碼來源:player.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:9,代碼來源:match.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:11,代碼來源:alias.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:11,代碼來源:alias.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:11,代碼來源:weapon.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:11,代碼來源:item.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:11,代碼來源:playermatch.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:13,代碼來源:player.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:12,代碼來源:player.go

示例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
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:13,代碼來源:match.go

示例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()
}
開發者ID:bboozzoo,項目名稱:q3stats,代碼行數:14,代碼來源:alias.go


注:本文中的github.com/bboozzoo/q3stats/store.DBConn類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。