Documentation
¶
Index ¶
- func BuildValidationErrorMsg(errs validator.ValidationErrors) string
- func Connect() *gorm.DB
- func GetDB() *gorm.DB
- func Insert(m Model) error
- func RunMigration()
- func Update(m Model) error
- type BaseModel
- type Entry
- type Label
- type Model
- type PartialEntry
- type PartialLabel
- type TwoFactorsCookie
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildValidationErrorMsg ¶
func BuildValidationErrorMsg(errs validator.ValidationErrors) string
func RunMigration ¶
func RunMigration()
Auto Migrate seems to fail to create foreign keys, hence creation of a many to many relation for entries / label failed
https://github.com/jinzhu/gorm/issues/450#issuecomment-487958084
Types ¶
type Entry ¶
type Entry struct {
BaseModel
PartialEntry
UserID uint
Labels []Label `json:"labels" gorm:"many2many:entry_labels;"`
}
The remaining data, generated by the server
type Label ¶
type Label struct {
BaseModel
PartialLabel
UserID uint `json:"user_id"`
AvatarUrl string `json:"avatar_url" gorm:"-"`
HasAvatar bool `json:"has_avatar"`
}
type PartialEntry ¶
type PartialEntry struct {
Content string `json:"content" gorm:"type:varchar"`
Title string `json:"title" gorm:"type:varchar" validate:"required,min=3"`
}
The user modifiable part of Entry
type PartialLabel ¶
type PartialLabel struct {
Name string `json:"name" validate:"alphanumunicode,max=100"`
Color string `json:"color" validate:"hexcolor"`
}
The user modifiable part
type TwoFactorsCookie ¶
type TwoFactorsCookie struct {
BaseModel
Uuid string `json:"-" validate:"uuid4" gorm:"type:varchar(36)"`
IpAddr string `json:"ip_addr" validate:"ipv4" gorm:"type:varchar(12)"`
UserAgent string `json:"user_agent" validate:"max=200" gorm:"type:varchar(200)"`
Expires time.Time `json:"expires"`
LastUsed time.Time `json:"last_used"`
UserID uint `json:"-"`
}
func (*TwoFactorsCookie) Create ¶
func (t *TwoFactorsCookie) Create() error
func (*TwoFactorsCookie) Delete ¶
func (t *TwoFactorsCookie) Delete() error
func (*TwoFactorsCookie) Update ¶
func (t *TwoFactorsCookie) Update() error
func (TwoFactorsCookie) Validate ¶
func (t TwoFactorsCookie) Validate() error
type User ¶
type User struct {
BaseModel
Email string `gorm:"type:varchar(100);unique_index" json:"email" validate:"email,required"`
Password string `gorm:"not null" json:"-"`
// todo find out if i can remove this
Entries []Entry `json:"-"`
Labels []Label `json:"-"`
TwoFactorsCookies []TwoFactorsCookie `json:"two_factors_cookies"`
// Stored encrypted
OTPSecret string `json:"-"`
HasRegisteredOTP bool `json:"has_registered_otp"`
}
Click to show internal directories.
Click to hide internal directories.