oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1package store
2
3import (
4 "errors"
5 "math"
6
7 "gorm.io/gorm"
8)
9
10const maxContentVersion uint64 = math.MaxInt64
11
12var errVersionExhausted = errors.New("store: content version exhausted")
13
14func (h *Handle) advanceContentVersion(tx *gorm.DB, version uint64) error {
15 if version >= maxContentVersion {
16 return errVersionExhausted
17 }
18 result := tx.Model(&Tab{}).Where("id = ?", h.tabID).
19 Select("content_version").Update("content_version", gorm.Expr("MAX(content_version, ?)", version))
20 if result.Error != nil {
21 return result.Error
22 }
23 if result.RowsAffected != 1 {
24 return gorm.ErrRecordNotFound
25 }
26 return nil
27}
28