improve documentation

This commit is contained in:
dhax 2017-09-27 22:42:43 +02:00
parent 232463e1db
commit 0826963742
16 changed files with 80 additions and 28 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/go-pg/pg/orm"
)
// Token holds refresh jwt information.
type Token struct {
ID int `json:"id,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
@ -18,6 +19,7 @@ type Token struct {
Identifier string `json:"identifier,omitempty"`
}
// BeforeInsert hook executed before database insert operation.
func (t *Token) BeforeInsert(db orm.DB) error {
now := time.Now()
if t.CreatedAt.IsZero() {
@ -27,6 +29,7 @@ func (t *Token) BeforeInsert(db orm.DB) error {
return nil
}
// BeforeUpdate hook executed before database update operation.
func (t *Token) BeforeUpdate(db orm.DB) error {
t.UpdatedAt = time.Now()
return nil