本文整理汇总了Golang中github.com/zond/kcwraps/kol.DB.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang DB.Get方法的具体用法?Golang DB.Get怎么用?Golang DB.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zond/kcwraps/kol.DB
的用法示例。
在下文中一共展示了DB.Get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Updated
func (self *Message) Updated(d *kol.DB, old *Message) {
g := Game{Id: self.GameId}
if err := d.Get(&g); err != nil {
panic(err)
}
d.EmitUpdate(&g)
}
示例2: Disallows
func (self Members) Disallows(d *kol.DB, asking *user.User) (result bool, err error) {
var askerList map[string]bool
if askerList, err = asking.Blacklistings(d); err != nil {
return
}
for _, member := range self {
if askerList[member.UserId.String()] {
result = true
return
}
}
for _, member := range self {
memberUser := &user.User{Id: member.UserId}
if err = d.Get(memberUser); err != nil {
return
}
var memberList map[string]bool
if memberList, err = memberUser.Blacklistings(d); err != nil {
return
}
if memberList[asking.Id.String()] {
result = true
return
}
}
return
}
示例3: Created
func (self *Member) Created(d *kol.DB) {
g := Game{Id: self.GameId}
if err := d.Get(&g); err != nil {
panic(err)
}
d.EmitUpdate(&g)
}
示例4: Deleted
func (self *Member) Deleted(d *kol.DB) {
g := Game{Id: self.GameId}
if err := d.Get(&g); err == nil {
d.EmitUpdate(&g)
} else if err != kol.NotFound {
panic(err)
}
}
示例5: Updated
func (self *Member) Updated(d *kol.DB, old *Member) {
if old != self {
g := Game{Id: self.GameId}
if err := d.Get(&g); err != nil {
panic(err)
}
d.EmitUpdate(&g)
}
}
示例6: Get
func Get(d *kol.DB) (result time.Duration, err error) {
epoch := &Epoch{
Id: kol.Id(epochKey),
}
if err = d.Get(epoch); err != nil {
if err == kol.NotFound {
err = nil
} else {
return
}
}
result = epoch.At + time.Now().Sub(time.Unix(0, atomic.LoadInt64(&deltaPoint)))
return
}
示例7: ReliabilityDelta
func (self *Member) ReliabilityDelta(d *kol.DB, i int) (err error) {
user := &user.User{Id: self.UserId}
if err = d.Get(user); err != nil {
return
}
if i > 0 {
user.HeldDeadlines += i
} else {
user.MissedDeadlines -= i
}
if err = d.Set(user); err != nil {
return
}
return
}
示例8: Users
func (self *Game) Users(d *kol.DB) (result user.Users, err error) {
members, err := self.Members(d)
if err != nil {
return
}
result = make(user.Users, len(members))
for index, member := range members {
user := user.User{Id: member.UserId}
if err = d.Get(&user); err != nil {
return
}
result[index] = user
}
return
}
示例9: ToState
func (self *Member) ToState(d *kol.DB, g *Game, email string, isMember bool, isAdmin bool) (result *MemberState, err error) {
result = &MemberState{
Member: &Member{
Id: self.Id,
},
User: &user.User{},
}
secretNation := false
secretEmail := false
secretNickname := false
var flag common.SecretFlag
switch g.State {
case common.GameStateCreated:
flag = common.SecretBeforeGame
case common.GameStateStarted:
flag = common.SecretDuringGame
case common.GameStateEnded:
flag = common.SecretAfterGame
default:
panic(fmt.Errorf("Unknown game state for %+v", g))
}
secretNation, secretEmail, secretNickname = g.SecretNation&flag == flag, g.SecretEmail&flag == flag, g.SecretNickname&flag == flag
isMe := string(self.UserId) == email
if isAdmin || isMe || !secretNation {
result.Member.Nation = self.Nation
}
if isAdmin || isMe || !secretEmail || !secretNickname {
foundUser := &user.User{Id: self.UserId}
if err = d.Get(foundUser); err != nil {
return
}
if isAdmin || (isMember && (isMe || !secretEmail)) {
result.User.Email = foundUser.Email
}
if isAdmin || (isMe || !secretNickname) {
result.User.Nickname = foundUser.Nickname
}
if isAdmin || isMe {
result.Member.Committed = self.Committed
result.Member.Options = self.Options
result.Member.NoOrders = self.NoOrders
}
}
return
}
示例10: Game
func (self *Phase) Game(d *kol.DB) (result *Game, err error) {
result = &Game{Id: self.GameId}
err = d.Get(result)
return
}