aboutsummaryrefslogtreecommitdiff
path: root/internal/db/access_tokens.go
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2022-06-04 13:35:42 +0800
committerGitHub <noreply@github.com>2022-06-04 13:35:42 +0800
commit4455cc1244f83a75e1ed665f4f49856744fe5482 (patch)
tree036c87f48888ad051cf48200308a5d3ff51824f9 /internal/db/access_tokens.go
parent38aff73251cc46ced96dd608dab6190415032a82 (diff)
db: code tidy up for `AccessTokens` (#7006)
Diffstat (limited to 'internal/db/access_tokens.go')
-rw-r--r--internal/db/access_tokens.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/db/access_tokens.go b/internal/db/access_tokens.go
index ab62c52d..a419a267 100644
--- a/internal/db/access_tokens.go
+++ b/internal/db/access_tokens.go
@@ -54,7 +54,7 @@ type AccessToken struct {
HasUsed bool `xorm:"-" gorm:"-" json:"-"`
}
-// NOTE: This is a GORM create hook.
+// BeforeCreate implements the GORM create hook.
func (t *AccessToken) BeforeCreate(tx *gorm.DB) error {
if t.CreatedUnix == 0 {
t.CreatedUnix = tx.NowFunc().Unix()
@@ -62,13 +62,13 @@ func (t *AccessToken) BeforeCreate(tx *gorm.DB) error {
return nil
}
-// NOTE: This is a GORM update hook.
+// BeforeUpdate implements the GORM update hook.
func (t *AccessToken) BeforeUpdate(tx *gorm.DB) error {
t.UpdatedUnix = tx.NowFunc().Unix()
return nil
}
-// NOTE: This is a GORM query hook.
+// AfterFind implements the GORM query hook.
func (t *AccessToken) AfterFind(tx *gorm.DB) error {
t.Created = time.Unix(t.CreatedUnix, 0).Local()
t.Updated = time.Unix(t.UpdatedUnix, 0).Local()