Stats #

Read more about the Stats system in Hiro here.

Functions #

List #

List all private stats for one or more users.

1
2
3
4
5
6
userIds := []string{"userId_001", "userId_002"}

stats, err := systems.GetStatsSystem().List(ctx, logger, nk, userIds)
if err != nil {
  return err
}

Update #

Update stats for a particular user.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
userId := "userId"
publicStats := []*hiro.StatUpdate{{
  Name:     "strength",
  Value:    1,
  Operator: hiro.StatUpdateOperator_STAT_UPDATE_OPERATOR_DELTA,
}}
privateStats := []*hiro.StatUpdate{{
  Name:     "dexterity",
  Value:    5,
  Operator: hiro.StatUpdateOperator_STAT_UPDATE_OPERATOR_SET,
}}

stats, err := systems.GetStatsSystem().Update(ctx, logger, nk, userId, publicStats, privateStats)
if err != nil {
  return err
}